refactor: changed error display

This commit is contained in:
antifallobst 2023-09-26 15:08:24 +02:00
parent da4fba9203
commit 6ecaf3d908
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
1 changed files with 3 additions and 6 deletions

View File

@ -46,7 +46,6 @@ impl Api {
match response.status() {
StatusCode::OK => (),
StatusCode::BAD_REQUEST => return Ok(Err(Error::msg("400 - Bad Request"))),
StatusCode::UNAUTHORIZED => return Ok(Err(Error::msg("Wrong password!"))),
StatusCode::FORBIDDEN => {
return Ok(Err(Error::msg("Blocked for security reasons!")))
@ -57,7 +56,7 @@ impl Api {
}
_ => {
return Ok(Err(Error::msg(format!(
"Unknown error: {}",
"Error: {}",
response.status().to_string()
))))
}
@ -82,14 +81,13 @@ impl Api {
match response.status() {
StatusCode::OK => (),
StatusCode::BAD_REQUEST => return Ok(Err(Error::msg("400 - Bad Request"))),
StatusCode::UNAUTHORIZED => return Ok(Err(Error::msg("Invalid token!"))),
StatusCode::FORBIDDEN => {
return Ok(Err(Error::msg("Blocked for security reasons!")))
}
_ => {
return Ok(Err(Error::msg(format!(
"Unknown error: {}",
"Error: {}",
response.status().to_string()
))))
}
@ -110,14 +108,13 @@ impl Api {
match response.status() {
StatusCode::OK => (),
StatusCode::BAD_REQUEST => return Ok(Err(Error::msg("400 - Bad Request"))),
StatusCode::FORBIDDEN => {
return Ok(Err(Error::msg("Blocked for security reasons!")))
}
StatusCode::NOT_FOUND => return Ok(Err(Error::msg("User not found"))),
_ => {
return Ok(Err(Error::msg(format!(
"Unknown error: {}",
"Error: {}",
response.status().to_string()
))))
}