-
Notifications
You must be signed in to change notification settings - Fork 129
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 #45 from tommady/issue-44-get-rid-of-error-chain-d…
…ependency Issue 44 get rid of error chain dependency
- Loading branch information
Showing
12 changed files
with
47 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
error_chain! { | ||
errors { | ||
InvalidParameter { description("invalid parameter") } | ||
DataItemIncomplete { description("data item is incomplete") } | ||
DataItemInvalid { description("data item is invalid") } | ||
use std::error::Error; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
pub type Result<T> = std::result::Result<T, TaError>; | ||
|
||
#[derive(Debug)] | ||
pub enum TaError { | ||
InvalidParameter, | ||
DataItemIncomplete, | ||
DataItemInvalid, | ||
} | ||
|
||
impl Display for TaError { | ||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { | ||
match *self { | ||
TaError::InvalidParameter => write!(f, "invalid parameter"), | ||
TaError::DataItemIncomplete => write!(f, "data item is incomplete"), | ||
TaError::DataItemInvalid => write!(f, "data item is invalid"), | ||
} | ||
} | ||
} | ||
|
||
impl Error for TaError { | ||
fn source(&self) -> Option<&(dyn Error + 'static)> { | ||
match *self { | ||
TaError::InvalidParameter => None, | ||
TaError::DataItemIncomplete => None, | ||
TaError::DataItemInvalid => 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
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
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