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
use core::{errors as core, ErrorPos};
use std::path::PathBuf;

error_chain! {
    links {
        Core(core::Error, core::ErrorKind);
    }

    foreign_links {
        Io(::std::io::Error);
        ParseInt(::std::num::ParseIntError);
        ParseFloat(::std::num::ParseFloatError);
        ParseBigIntError(::num::bigint::ParseBigIntError);
    }

    errors {
        Pos(message: String, pos: ErrorPos) {
            description("position error")
            display("{}", message)
        }

        File(message: String, file: PathBuf) {
            description("file error")
            display("{}: {}", file.display(), message)
        }

        Syntax(pos: Option<ErrorPos>, expected: Vec<String>) {
            description("syntax error")
        }

        Parse(message: &'static str, pos: ErrorPos) {
            description("parse error")
            display("parse error: {}", message)
        }
    }
}