File size: 1,264 Bytes
74f2b46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use thiserror::Error;
use alloy::providers::PendingTransactionError;
use alloy::transports::TransportErrorKind;

#[derive(Debug, Error)]
pub enum AppError {
    #[error("invalid request: {0}")]
    InvalidRequest(String),

    #[error("redaction failed: {0}")]
    Redaction(String),

    #[error("inference failed: {0}")]
    Inference(String),

    #[error("medical enrichment failed: {0}")]
    Medical(String),

    #[error("audit failed: {0}")]
    Audit(String),

    #[error(transparent)]
    Http(#[from] reqwest::Error),

    #[error(transparent)]
    Json(#[from] serde_json::Error),

    #[error(transparent)]
    Io(#[from] std::io::Error),

    #[error(transparent)]
    Chrono(#[from] chrono::ParseError),

    #[error(transparent)]
    Other(#[from] anyhow::Error),
}

impl From<axum::Error> for AppError {
    fn from(e: axum::Error) -> Self {
        AppError::Other(anyhow::anyhow!(e))
    }
}

impl From<RpcError<TransportErrorKind>> for AppError {
    fn from(e: RpcError<TransportErrorKind>) -> Self {
        AppError::Other(anyhow::anyhow!(e))
    }
}

impl From<PendingTransactionError> for AppError {
    fn from(e: PendingTransactionError) -> Self {
        AppError::Other(anyhow::anyhow!(e))
    }
}
use alloy::rpc::json_rpc::RpcError;