-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from B-urb/feature/default-fields
Feature/default fields
- Loading branch information
Showing
7 changed files
with
381 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::fmt; | ||
|
||
#[derive(Debug)] | ||
pub enum ResponseError { | ||
Io(std::io::Error), | ||
ParseBody(std::num::ParseIntError), | ||
RequestError(std::io::Error), | ||
Other(String), | ||
} | ||
|
||
// Step 2: Implement std::fmt::Display | ||
impl fmt::Display for ResponseError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match *self { | ||
ResponseError::Io(ref err) => write!(f, "IO error: {}", err), | ||
ResponseError::ParseBody(ref err) => write!(f, "Parse error: {}", err), | ||
ResponseError::RequestError(ref err) => write!(f, "Parse error: {}", err), | ||
ResponseError::Other(ref err) => write!(f, "Other error: {}", err), | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for ResponseError { | ||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { | ||
match *self { | ||
ResponseError::Io(ref err) => Some(err), | ||
ResponseError::ParseBody(ref err) => Some(err), | ||
ResponseError::RequestError(ref err) => Some(err), | ||
ResponseError::Other(_) => None, | ||
} | ||
} | ||
} | ||
|
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
Oops, something went wrong.