edc_connector_client/
error.rs1use reqwest::StatusCode;
2use serde::Deserialize;
3
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 #[error(transparent)]
7 Reqwest(#[from] reqwest::Error),
8
9 #[error(transparent)]
10 ManagementApi(ManagementApiError),
11
12 #[error(transparent)]
13 Auth(#[from] Box<dyn std::error::Error + Send + Sync>),
14}
15
16#[derive(Debug, thiserror::Error)]
17#[error("Connector management api returned {status_code}")]
18pub struct ManagementApiError {
19 pub status_code: StatusCode,
20 pub error_detail: ManagementApiErrorDetailKind,
21}
22
23#[derive(Debug, Deserialize)]
24pub struct ManagementApiErrorDetail {
25 pub message: String,
26 #[serde(rename = "type")]
27 pub kind: String,
28}
29
30#[derive(Debug)]
31pub enum ManagementApiErrorDetailKind {
32 Raw(String),
33 Parsed(Vec<ManagementApiErrorDetail>),
34}
35
36#[derive(Debug, thiserror::Error)]
37pub enum BuilderError {
38 #[error("Missing mandatory property {0}")]
39 MissingProperty(String),
40}
41
42impl BuilderError {
43 pub fn missing_property(property: &str) -> BuilderError {
44 BuilderError::MissingProperty(property.to_string())
45 }
46}
47
48#[derive(Debug, thiserror::Error, PartialEq)]
49#[error("Failed to convert")]
50pub struct ConversionError {}