error: implement std::error::Error.
This commit is contained in:
parent
79804e2b01
commit
f83e9fd928
1 changed files with 15 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ use base64;
|
||||||
use chrono;
|
use chrono;
|
||||||
use jid;
|
use jid;
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
|
use std::error::Error as StdError;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::net;
|
use std::net;
|
||||||
use std::num;
|
use std::num;
|
||||||
|
|
@ -46,6 +47,20 @@ pub enum Error {
|
||||||
ChronoParseError(chrono::ParseError),
|
ChronoParseError(chrono::ParseError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl StdError for Error {
|
||||||
|
fn cause(&self) -> Option<&dyn StdError> {
|
||||||
|
match self {
|
||||||
|
Error::ParseError(_) => None,
|
||||||
|
Error::Base64Error(e) => Some(e),
|
||||||
|
Error::ParseIntError(e) => Some(e),
|
||||||
|
Error::ParseStringError(e) => Some(e),
|
||||||
|
Error::ParseAddrError(e) => Some(e),
|
||||||
|
Error::JidParseError(e) => Some(e),
|
||||||
|
Error::ChronoParseError(e) => Some(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue