use std::io;
use git2;
use serde_json;
use std::error;
use std::fmt;
use std::convert::From;
#[derive(Debug)]
pub enum ErrorKind {
IO,
Git,
JSON
}
#[derive(Debug)]
pub struct Error {
kind: ErrorKind,
message: String
}
impl error::Error for Error {
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<Ellipsis error with desc: {}", self.to_string())
}
}
impl From<io::Error> for Error {
fn from(e : io::Error) -> Self {
Error {
kind: ErrorKind::IO,
message: e.to_string()
}
}
}
impl From<git2::Error> for Error {
fn from(e : git2::Error) -> Self {
Error {
kind: ErrorKind::Git,
message: e.to_string()
}
}
}
impl From<serde_json::Error> for Error {
fn from (e : serde_json::Error) -> Self {
Error {
kind: ErrorKind::JSON,
message: e.to_string()
}
}
}