1error_chain! {
2 foreign_links {
3 IOError(::std::io::Error);
4 InvalidUtf8(::std::string::FromUtf8Error);
5 }
6
7 errors {
8 InvalidCase(v: i32) {
9 description("invalid union case")
10 display("invalid union case: '{}'", v)
11 }
12 InvalidEnum(v: i32) {
13 description("invalid enum value")
14 display("invalid enum value: '{}'", v)
15 }
16 InvalidLen(v: usize) {
17 description("invalid array len")
18 display("invalid array len: '{}'", v)
19 }
20 }
21}
22
23unsafe impl Sync for Error {}
24
25impl Error {
26 pub fn invalidcase(v: i32) -> Error {
27 ErrorKind::InvalidCase(v).into()
28 }
29
30 pub fn invalidenum(v: i32) -> Error {
31 ErrorKind::InvalidEnum(v).into()
32 }
33
34 pub fn invalidlen(v: usize) -> Error {
35 ErrorKind::InvalidLen(v).into()
36 }
37}