1use std::{env::VarError, string::FromUtf8Error};
2
3use reqwest::header::InvalidHeaderValue;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
8pub enum Error {
9 #[error("An error occurred when processing a request: {0}")]
11 ClientError(#[from] reqwest::Error),
12 #[error("Invalid configuration provided: {0}")]
14 InvalidConfiguration(#[from] InvalidHeaderValue),
15 #[error("Parsing error has occurred: {0}")]
17 ParsingError(String),
18 #[cfg(any(feature = "json", feature = "functions"))]
20 #[error("Failed to (de)serialize data: {0}")]
21 SerdeJsonError(#[from] serde_json::Error),
22 #[error("Failed to (de)serialize data: {0}")]
24 #[cfg(feature = "postcard")]
25 PostcardError(#[from] postcard::Error),
26 #[error("Failed to parse string from UTF-8: {0}")]
28 StringError(#[from] FromUtf8Error),
29 #[error("An error (type: {error_type}) occurred on the API backend: {message}")]
31 BackendError {
32 message: String,
34 error_type: String,
36 },
37 #[error("Error happened during an IO operation: {0}")]
39 IOError(#[from] tokio::io::Error),
40 #[error("Error while trying to access an environment variable: {0}")]
42 VarError(#[from] VarError),
43}