1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
use backend::errors as backend; use codeviz::errors as codeviz; use parser::ast; use parser::errors as parser; use std::path::PathBuf; #[derive(Debug)] pub enum InternalError { ParseError, } impl ::std::fmt::Display for InternalError { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { ::std::fmt::Debug::fmt(self, f) } } impl ::std::error::Error for InternalError { fn description(&self) -> &str { "Internal Error" } } error_chain! { links { Parser(parser::Error, parser::ErrorKind); Codeviz(codeviz::Error, codeviz::ErrorKind); } foreign_links { Io(::std::io::Error); Log(::log::SetLoggerError); ParseError(InternalError); BackendError(backend::Error); } errors { BackendErrors(errors: Vec<backend::Error>) { description("backend errors") display("Encountered {} backend error(s)", errors.len()) } MissingBackend { } DeclError(path: PathBuf, line_string: String, line: usize, decl: ast::Decl) { description("Error in declaration") display("Error in declaration `{}`: {}:{}: `{}`", decl.display(), path.display(), line, line_string) } DeclConflict(path: PathBuf, line_string: String, line: usize, existing: ast::Decl, conflicting: ast::Decl) { description("Conflicting type declared") display("Conflicting type declared: {}:{}: `{}`", path.display(), line, line_string) } InvalidMerge(this: ast::Decl, other: ast::Decl) { description("Invalid merge") display("Cannot merge existing `{}` with `{}`", this.display(), other.display()) } } } impl From<Vec<backend::Error>> for Error { fn from(errors: Vec<backend::Error>) -> Error { ErrorKind::BackendErrors(errors).into() } }