refactor: changed error display
This commit is contained in:
parent
da4fba9203
commit
6ecaf3d908
|
@ -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()
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue