carbone_sdk_rust/errors/
mod.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
4#[non_exhaustive]
5pub enum CarboneError {
6 #[error("Carbone SDK error: {0:?}")]
7 Error(String),
8 #[error("CarboneSDK: error: {0:?} can not be empty")]
9 EmptyString(String),
10 #[error("CarboneSDK: Unknown Server Error")]
11 ServerError,
12 #[error("CarboneSDK: render_id: \"{0:?}\" not found")]
13 RenderIdNotFound(String),
14 #[error("CarboneSDK: template_id: \"{0:?}\" not found")]
15 TemplateIdNotFound(String),
16 #[error("CarboneSDK: template file: \"{0:?}\" not found")]
17 TemplateFileNotFound(String),
18 #[error("Carbone SDK error: file {0:?} not found")]
19 FileNotFound(String),
20 #[error("Carbone SDK {0:?} is a directory")]
21 IsADirectory(String),
22 #[error("Carbone SDK IoError {0:?}")]
23 IoError(#[from] std::io::Error),
24 #[error("Carbone SDK RequestError {0:?}")]
25 RequestError(#[from] reqwest::Error),
26 #[error("Carbone SDK ResponseError {0:?}")]
27 ResponseError(String),
28 #[error("Carbone SDK RequestBodyNotWellFormedJsonError")]
29 RequestBodyNotWellFormedJsonError,
30 #[error("Carbone SDK {0:?} ParseError {1:?}")]
31 ParseError(String, String),
32 #[error("Carbone SDK HttpError: {status_code:?} - {error_message}")]
33 HttpError {
34 status_code: reqwest::StatusCode,
35 error_message: String,
36 },
37}
38
39impl From<anyhow::Error> for CarboneError {
40 fn from(err: anyhow::Error) -> Self {
41 CarboneError::Error(err.to_string())
42 }
43}