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
use error_chain::error_chain;
use std::fmt;
use std::io;
use std::path::PathBuf;

error_chain! {
    // The type defined for this error
    types {
        Error, ErrorKind, ResultExt;
    }

    // Automatic conversions between this error chain and other error types
    foreign_links {
        FmtError(fmt::Error);
        IoError(io::Error);
        ParseError(syn::Error);
        RegexError(regex::Error);
    }

    // Custom errors
    errors {
        SourceFileNotFound(p: PathBuf) {
            description("Source file not found"),
            display("Source file {:?} not found", p)
        }
        InvalidRuleName(name: String) {
            description("Invalid Rule name"),
            display("Invalid Rule name: {:?}", name)
        }
    }
}