fundamentum_sdk_api/client/errors.rs
1//! Contains all errors in this client side crate
2
3pub use reqwest::{Error as ReqwestError, StatusCode};
4
5use crate::models::api_response::ApiResponse;
6use displaydoc::Display;
7use std::path::PathBuf;
8use thiserror::Error;
9
10/// All possible errors coming from the SDK Client.
11#[derive(Error, Debug, Display)]
12pub enum SdkClientError {
13 /// Cannot parse the base path to a url: {0}
14 BasePathError(#[source] url::ParseError),
15 /// Cannot join a path to base path
16 JoinPathError(PathBuf),
17 /// Reqwest crate errors
18 ReqwestError(#[source] ReqwestError),
19 /** Error interpreting the HTTP Response body to Json ({1})
20 * {0:#?}
21 **/
22 BodyToJsonError(#[source] ReqwestError, StatusCode),
23 /// Error interpreting the `.data` field into T
24 DataToJsonError(#[source] serde_json::Error),
25 /// Missing the 'status' field in Json response ({1})
26 MissingMessageField(ApiResponse, StatusCode),
27 /// Missing the 'message' field in Json response when status is 'error' ({1})
28 MissingStatusField(ApiResponse, StatusCode),
29 /** Error coming from the Api ({2}): {0}
30 * {1:#?}
31 **/
32 GenericApiError(String, ApiResponse, StatusCode),
33}