improve some errors

This commit is contained in:
Bryan Stitt 2022-12-23 12:17:14 -08:00
parent 11a7aff8e0
commit 9bcbadd81a
3 changed files with 9 additions and 9 deletions

@ -85,10 +85,7 @@ impl CheckConfigSubCommand {
if num_errors == 0 {
Ok(())
} else {
Err(anyhow::anyhow!(format!(
"there were {} errors!",
num_errors
)))
Err(anyhow::anyhow!("there were {} errors!", num_errors))
}
}
}

@ -243,7 +243,7 @@ impl Authorization {
None => {}
Some(allowed_ips) => {
if !allowed_ips.iter().any(|x| x.contains(&ip)) {
return Err(anyhow::anyhow!("IP is not allowed!"));
return Err(anyhow::anyhow!("IP ({}) is not allowed!", ip));
}
}
}
@ -255,7 +255,7 @@ impl Authorization {
(None, Some(_)) => return Err(anyhow::anyhow!("Origin required")),
(Some(origin), Some(allowed_origins)) => {
if !allowed_origins.contains(origin) {
return Err(anyhow::anyhow!("IP is not allowed!"));
return Err(anyhow::anyhow!("Origin ({}) is not allowed!", origin));
}
}
}
@ -267,7 +267,7 @@ impl Authorization {
(None, Some(_)) => return Err(anyhow::anyhow!("Referer required")),
(Some(referer), Some(allowed_referers)) => {
if !allowed_referers.contains(referer) {
return Err(anyhow::anyhow!("Referer is not allowed!"));
return Err(anyhow::anyhow!("Referer ({:?}) is not allowed!", referer));
}
}
}
@ -279,7 +279,10 @@ impl Authorization {
(None, Some(_)) => return Err(anyhow::anyhow!("User agent required")),
(Some(user_agent), Some(allowed_user_agents)) => {
if !allowed_user_agents.contains(user_agent) {
return Err(anyhow::anyhow!("User agent is not allowed!"));
return Err(anyhow::anyhow!(
"User agent ({}) is not allowed!",
user_agent
));
}
}
}

@ -253,7 +253,7 @@ async fn handle_socket_payload(
FrontendErrorResponse::Anyhow(err) => Err(err),
_ => {
error!("handle this better! {:?}", err);
Err(anyhow::anyhow!(format!("unexpected error! {:?}", err)))
Err(anyhow::anyhow!("unexpected error! {:?}", err))
}
},
|(response, _)| Ok(response),