Skip to main content

forge/mt/
error.rs

1use core::fmt;
2
3pub type MtResult<T> = Result<T, MtError>;
4
5pub enum MtError {
6    // General
7    DtiNotFound(&'static str),
8
9    // Dti
10    FailedToCreateInstance(&'static str),
11
12    // fs
13    FailedToOpenFile,
14}
15
16impl fmt::Display for MtError {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        match self {
19            MtError::DtiNotFound(dti) => write!(f, "Could not find Dti: {dti}"),
20            MtError::FailedToCreateInstance(type_name) => write!(f, "Could not create instance of type {type_name}"),
21            MtError::FailedToOpenFile => write!(f, "Could not open file"),
22        }
23    }
24}