sanity_rs/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4/// Represents errors that can occur during a request.
5pub enum RequestError {
6    /// Error during URL parsing.
7    #[error("URL Parsing error: {0}")]
8    URLParsingError(#[from] URLError),
9
10    /// Error during the Reqwest request.
11    #[error("Reqwest error: {0}")]
12    ReqwestError(#[from] reqwest::Error),
13
14    /// Error during JSON parsing.
15    #[error("JSON parsing error: {0}")]
16    JsonParsingError(#[from] serde_json::Error),
17
18    /// Error when a required environment variable is missing.
19    #[error("Missing Env error: {0}")]
20    MissingEnvVarError(#[from] std::env::VarError),
21
22    /// A generic string error for request failures.
23    #[error("Request error: {0}")]
24    StringParsingError(String),
25}
26
27#[derive(Error, Debug)]
28/// Represents errors that can occur when working with URLs.
29pub enum URLError {
30    /// Indicates an invalid URL.  Wraps a `url::ParseError`.
31    #[error("Invalid URL: {0}")]
32    InvalidURL(#[from] url::ParseError),
33}
34
35#[derive(Error, Debug)]
36/// Configuration errors that can occur during application initialization.
37pub enum ConfigurationError {
38    /// The project ID was not provided in the configuration.
39    #[error("Missing project ID")]
40    MissingProjectID,
41
42    /// The dataset was not specified in the configuration.
43    #[error("Missing dataset")]
44    MissingDataset,
45}