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