icinga2_api/
error.rs

1//! The error type for the library
2
3use thiserror::Error;
4
5use crate::types::enums::object_type::IcingaObjectType;
6
7/// Error type for icinga2_api
8#[derive(Debug, Error)]
9pub enum Error {
10    /// could not read config file
11    #[error("could not read config file: {0}")]
12    CouldNotReadConfigFile(std::io::Error),
13    /// could not parse config
14    #[error("could not parse config: {0}")]
15    CouldNotParseConfig(toml::de::Error),
16    /// could not parse URL in config
17    #[error("could not parse URL in config: {0}")]
18    CouldNotParseUrlInConfig(url::ParseError),
19    /// could not build reqwest client from supplied information
20    #[error("could not build reqwest client from supplied information: {0}")]
21    CouldNotBuildReqwestClientFromSuppliedInformation(reqwest::Error),
22    /// could not read CA certificate file
23    #[error("could not read CA certificate file: {0}")]
24    CouldNotReadCACertFile(std::io::Error),
25    /// could not parse PEM CA certificate
26    #[error("could not parse PEM CA certificate: {0}")]
27    CouldNotParsePEMCACertificate(reqwest::Error),
28    /// An error occurred when serializing/deserializing JSON
29    #[error("error in json serialization/deserialization: {0}")]
30    SerdeJsonError(#[from] serde_path_to_error::Error<serde_json::Error>),
31    /// Response body was empty so we can not deserialize it as JSON
32    #[error("empty response body with status: {0}")]
33    EmptyResponseBody(reqwest::StatusCode),
34    /// An error occurred in the reqwest library (HTTP)
35    #[error("reqwest error: {0}")]
36    ReqwestError(#[from] reqwest::Error),
37    /// could not parse URL fragment
38    #[error("could not parse URL fragment: {0}")]
39    CouldNotParseUrlFragment(url::ParseError),
40    /// the object type of a query filter did not match the query result object
41    #[error("filter object type expected one of {0:?} but was {1}")]
42    FilterObjectTypeMismatch(Vec<IcingaObjectType>, IcingaObjectType),
43    /// uninitialized field in builder
44    #[error("uninitialized field in builder: {0}")]
45    UninitializedFieldInBuilder(#[from] derive_builder::UninitializedFieldError),
46    /// all_services invalid when targeting a service
47    #[error("all_services is invalid when targeting a service for a downtime")]
48    AllServicesInvalidOnServiceDowntime,
49    /// duration parameter is required for flexible downtimes but not for fixed ones
50    #[error("duration is required for flexible downtimes")]
51    DurationRequiredOnFlexibleDowntime,
52}