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 serde::{Deserialize, Serialize};
use std::time::{SystemTime, UNIX_EPOCH};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct BundError {
    ts:         std::time::SystemTime,
    eclass:     String,
    msg:        String,
}

impl BundError {
    pub fn new(t: String, msg: String) -> Self {
        Self {
            ts:             SystemTime::now(),
            eclass:         t,
            msg:            msg,
        }
    }
}

impl BundError {
    pub fn millisecond(&self) -> i64 {
        self.ts.duration_since(UNIX_EPOCH).unwrap().as_millis() as i64
    }
    pub fn message(&self) -> &String {
        &self.msg
    }
    pub fn class(&self) -> &String {
        &self.eclass
    }
}