forked from lavina/lavina
1
0
Fork 0

xmpp: no panic! (#29)

Reviewed-on: lavina/lavina#29
Co-authored-by: JustTestingV <JustTestingV@gmail.com>
Co-committed-by: JustTestingV <JustTestingV@gmail.com>
This commit is contained in:
JustTestingV 2024-01-22 15:13:19 +00:00 committed by Nikita Vilunov
parent 77d175ccd9
commit 614be92be3
2 changed files with 4 additions and 4 deletions

View File

@ -83,7 +83,7 @@ pub async fn launch(
let key = match read_one(&mut SyncBufReader::new(File::open(config.key)?))? { let key = match read_one(&mut SyncBufReader::new(File::open(config.key)?))? {
Some(PemItem::ECKey(k) | PemItem::PKCS8Key(k) | PemItem::RSAKey(k)) => PrivateKey(k), Some(PemItem::ECKey(k) | PemItem::PKCS8Key(k) | PemItem::RSAKey(k)) => PrivateKey(k),
_ => panic!("no keys in file"), _ => return Err(fail("no keys in file")),
}; };
let loaded_config = Arc::new(LoadedConfig { let loaded_config = Arc::new(LoadedConfig {

View File

@ -28,10 +28,10 @@ impl ClientStreamStart {
if let Event::Start(e) = incoming { if let Event::Start(e) = incoming {
let (ns, local) = reader.resolve_element(e.name()); let (ns, local) = reader.resolve_element(e.name());
if ns != ResolveResult::Bound(Namespace(XMLNS.as_bytes())) { if ns != ResolveResult::Bound(Namespace(XMLNS.as_bytes())) {
return Err(panic!()); return Err(anyhow!("Invalid namespace for stream element"));
} }
if local.into_inner() != b"stream" { if local.into_inner() != b"stream" {
return Err(panic!()); return Err(anyhow!("Invalid local name for stream element"));
} }
let mut to = None; let mut to = None;
let mut lang = None; let mut lang = None;
@ -64,7 +64,7 @@ impl ClientStreamStart {
version: version.unwrap(), version: version.unwrap(),
}) })
} else { } else {
Err(panic!()) Err(anyhow!("Incoming message does not belong XML Start Event"))
} }
} }
} }