1
2#[derive(Debug)]
4pub enum TypeError {
5 InvalidPrice(String),
6 InvalidString(String, String),
7 InvalidTime(u64),
8}
9
10use std::fmt;
11
12impl fmt::Display for TypeError {
13 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14
15 let msg = match self {
16 TypeError::InvalidPrice(val) => format!("Price: {}", val),
17 TypeError::InvalidString(k, val) => format!("{}: {}", k, val),
18 TypeError::InvalidTime(val) => format!("Time: {} (nanosec)", val),
19 };
20
21 write!(f, "Invalid Type - {}", msg)
22 }
23}
24
25impl std::error::Error for TypeError {}
26