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
32
33
34
35
36
37
38
39
use std::fmt;

#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum RegistrationError {
    AlreadyRegistered(String),
    UnknownError(),
}

impl fmt::Display for RegistrationError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            RegistrationError::AlreadyRegistered(name) => f.write_fmt(format_args!(
                "A nanotransaction with the specified name ({}) has already been registered.",
                name,
            )),
            _ => write!(f, "An unknown error occured"),
        }
    }
}

#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum ExecutionError {
    TransactionNotFound(String),
    UnknownError(),
}

impl fmt::Display for ExecutionError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            ExecutionError::TransactionNotFound(name) => f.write_fmt(format_args!(
                "No nanotransaction with the name `{}` has been registered.",
                name,
            )),
            _ => write!(f, "An unknown error occured"),
        }
    }
}