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)?))? {
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 {

View File

@ -28,10 +28,10 @@ impl ClientStreamStart {
if let Event::Start(e) = incoming {
let (ns, local) = reader.resolve_element(e.name());
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" {
return Err(panic!());
return Err(anyhow!("Invalid local name for stream element"));
}
let mut to = None;
let mut lang = None;
@ -64,7 +64,7 @@ impl ClientStreamStart {
version: version.unwrap(),
})
} else {
Err(panic!())
Err(anyhow!("Incoming message does not belong XML Start Event"))
}
}
}