-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
24 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,11 @@ | ||
use std::fmt; | ||
|
||
#[derive(Debug)] | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
RequestFailed(reqwest::Error), | ||
DeserializeFailed(serde_json::error::Error), | ||
ApiErrorResponse(String), | ||
} | ||
|
||
impl std::error::Error for Error {} | ||
#[error("Unable to send the request: {0}")] | ||
RequestFailed(#[from] reqwest::Error), | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
Self::RequestFailed(e) => { | ||
write!(f, "Unable to send the request: {}", e) | ||
} | ||
Self::DeserializeFailed(e) => { | ||
write!(f, "Unable to deserialize the received value: {}", e) | ||
} | ||
Self::ApiErrorResponse(e) => { | ||
write!(f, "API returned an error response: {}", e) | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl From<serde_json::error::Error> for Error { | ||
fn from(error: serde_json::error::Error) -> Self { | ||
Self::DeserializeFailed(error) | ||
} | ||
} | ||
#[error("Unable to deserialize the received value: {0}")] | ||
DeserializeFailed(#[from] serde_json::error::Error), | ||
|
||
impl From<reqwest::Error> for Error { | ||
fn from(error: reqwest::Error) -> Self { | ||
Self::RequestFailed(error) | ||
} | ||
#[error("API returned an error response: {0}")] | ||
ApiErrorResponse(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters