market_flow/model/
error.rs1#[derive(Debug)]
5pub enum MarketFlowError {
6 DeserializationError(serde_json::error::Error),
8 IOError(std::io::Error),
10}
11
12impl From<std::io::Error> for MarketFlowError {
13 fn from(error: std::io::Error) -> Self {
14 MarketFlowError::IOError(error)
15 }
16}
17
18impl From<serde_json::error::Error> for MarketFlowError {
19 fn from(value: serde_json::error::Error) -> Self {
20 MarketFlowError::DeserializationError(value)
21 }
22}
23
24impl std::error::Error for MarketFlowError {
25 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
26 match self {
27 MarketFlowError::DeserializationError(e) => Some(e),
28 MarketFlowError::IOError(e) => Some(e),
29 }
30 }
31}
32
33impl std::fmt::Display for MarketFlowError {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 match self {
36 MarketFlowError::DeserializationError(e) => {
37 write!(f, "failed to parse market event: {e}")
38 }
39 MarketFlowError::IOError(e) => write!(f, "market data I/O error: {e}"),
40 }
41 }
42}