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
use std::fmt;
use std::error::Error;

#[derive(Debug)]
pub struct UltraNLPError {
    message: String,
}

impl UltraNLPError {
    pub fn new<T: AsRef<str>>(message: T) -> Self {
        let message = message.as_ref().to_string();

        Self { message }
    }
}

impl fmt::Display for UltraNLPError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.message)
    }
}

impl Error for UltraNLPError {}

pub type UltraNLPResult<T, E = UltraNLPError> = Result<T, E>;