Skip to main content

aep_core/
error.rs

1use thiserror::Error;
2
3use crate::ErrorCode;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
6pub struct ValidationIssue {
7    pub message: String,
8    pub path: String,
9}
10
11#[derive(Clone, Debug, Error, Eq, PartialEq)]
12#[error("invalid AEP {document_type}")]
13pub struct ValidationError {
14    pub document_type: String,
15    pub issues: Vec<ValidationIssue>,
16}
17
18#[derive(Debug, Error)]
19pub enum ParseError {
20    #[error("invalid JSON in AEP {document_type}: {source}")]
21    Json {
22        document_type: String,
23        #[source]
24        source: serde_json::Error,
25    },
26    #[error(transparent)]
27    Validation(#[from] ValidationError),
28}
29
30#[derive(Clone, Debug, Error, Eq, PartialEq)]
31#[error("{message}")]
32pub struct AuthorizationCarrierError {
33    pub code: ErrorCode,
34    pub message: String,
35}
36
37#[derive(Debug, Error)]
38pub enum CoreError {
39    #[error("{0}")]
40    Invalid(String),
41    #[error("invalid AEP JWT: {0}")]
42    Jwt(String),
43    #[error(transparent)]
44    Json(#[from] serde_json::Error),
45    #[error(transparent)]
46    Transport(#[from] crate::TransportError),
47    #[error(transparent)]
48    Url(#[from] url::ParseError),
49    #[error(transparent)]
50    Validation(#[from] ValidationError),
51}