use std::fmt;
use std::error::Error;
use std::io::Error as IoError;
use chrono::ParseError;
#[derive(Debug, PartialEq, Default, RustcDecodable, RustcEncodable)]
pub struct CredentialsError{
pub message: String
}
impl CredentialsError {
pub fn new(message: &str) -> CredentialsError {
CredentialsError {
message: message.to_string()
}
}
}
impl fmt::Display for CredentialsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CredentialsError {
fn description(&self) -> &str {
&self.message
}
}
impl From<ParseError> for CredentialsError {
fn from(err: ParseError) -> CredentialsError {
CredentialsError::new(err.description())
}
}
impl From<IoError> for CredentialsError {
fn from(err: IoError) -> CredentialsError {
CredentialsError::new(err.description())
}
}