1use std::fmt;
4
5#[derive(Debug)]
7pub enum ChioTowerError {
8 Evaluation(String),
10 ReceiptSign(String),
12 ReceiptPersist(String),
17 IdentityExtraction(String),
19 Inner(Box<dyn std::error::Error + Send + Sync>),
21}
22
23impl fmt::Display for ChioTowerError {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 match self {
26 Self::Evaluation(msg) => write!(f, "Chio evaluation error: {msg}"),
27 Self::ReceiptSign(msg) => write!(f, "Chio receipt signing error: {msg}"),
28 Self::ReceiptPersist(msg) => write!(f, "Chio receipt persistence error: {msg}"),
29 Self::IdentityExtraction(msg) => write!(f, "Chio identity extraction error: {msg}"),
30 Self::Inner(err) => write!(f, "inner service error: {err}"),
31 }
32 }
33}
34
35impl std::error::Error for ChioTowerError {
36 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
37 match self {
38 Self::Inner(err) => Some(err.as_ref()),
39 _ => None,
40 }
41 }
42}