Better error message for reqwest error
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c4a8251147
commit
bf67cf62f9
1 changed files with 13 additions and 1 deletions
|
@ -57,7 +57,19 @@ impl IntoResponse for APIError {
|
||||||
impl ServiceError {
|
impl ServiceError {
|
||||||
fn get_response_message(&self) -> String {
|
fn get_response_message(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
ServiceError::Reqwest(_) => "Reqwest error".to_string(),
|
ServiceError::Reqwest(err) => {
|
||||||
|
format!(
|
||||||
|
"URL: {}, Status Code: {}",
|
||||||
|
match err.url() {
|
||||||
|
Some(url) => url.to_string(),
|
||||||
|
None => "No URL in error".to_string(),
|
||||||
|
},
|
||||||
|
match err.status() {
|
||||||
|
Some(code) => code.to_string(),
|
||||||
|
None => "No Status Code in error".to_string(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
ServiceError::Url(_) => "URL parse error".to_string(),
|
ServiceError::Url(_) => "URL parse error".to_string(),
|
||||||
ServiceError::InvalidResponse(code) => format!("Invalid response code: {}", code),
|
ServiceError::InvalidResponse(code) => format!("Invalid response code: {}", code),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue