etanol_utils/utils/
error.rs

1use ansi_term::Colour;
2
3pub struct EtanolError {}
4
5impl EtanolError {
6    fn block(msg: String) -> String {
7        let white = Colour::White.bold();
8        let red = Colour::Red.bold();
9
10        format!("{}{}{}", white.paint("["), red.paint(msg), white.paint("]"))
11    }
12
13    pub fn new(reason: String, errorType: String) {
14        let white = Colour::White.bold();
15        let block = EtanolError::block("EtanolError".to_string());
16
17        println!("{} {}", block, white.paint(errorType));
18        println!("{}", reason);
19
20        std::process::exit(1);
21    }
22}