#![allow(renamed_and_removed_lints)]
use std::{fmt, io};
error_chain!{
types {
Error, ErrorKind, ResultExt;
}
foreign_links {
Io(::std::io::Error);
}
}
pub type Result<T> = ::std::result::Result<T, Error>;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TaskError {
message: String,
}
impl<'a> From<&'a str> for TaskError {
fn from(msg: &'a str) -> TaskError {
TaskError {
message: msg.into(),
}
}
}
impl From<String> for TaskError {
fn from(msg: String) -> TaskError {
TaskError { message: msg }
}
}
impl From<io::Error> for TaskError {
fn from(err: io::Error) -> TaskError {
TaskError {
message: format!("{}", err),
}
}
}
impl<'a> fmt::Display for TaskError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "task error: {}", self.message)
}
}
pub type TaskResult<T> = ::std::result::Result<T, TaskError>;