use std::io::IoError;
use std::error::FromError;
use std::fmt::{Show, Formatter, Error};
pub type AppResult<T> = Result<T, AppError>;
pub struct AppError
{
error: String
}
impl AppError
{
pub fn from_string(string: String) -> AppError
{
AppError { error: string }
}
}
impl Show for AppError
{
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
{
writeln!(f, "{}", self.error)
}
}
impl FromError<IoError> for AppError
{
fn from_error(err: IoError) -> AppError
{
AppError { error: format!("{}", err) }
}
}