tfc_toolset/
error.rs

1use thiserror::Error;
2
3pub const SETTINGS_ERROR: &str = "Uh Oh, looks like a settings issue! By default I look for a settings.toml file and override with env variables.";
4
5pub(crate) fn surf_to_tool_error(e: surf::Error) -> ToolError {
6    ToolError::General(e.into_inner())
7}
8
9/// A generic “error” type
10#[derive(Error, Debug)]
11pub enum ToolError {
12    /// A general error used as a catch all for other errors via anyhow
13    #[error(transparent)]
14    General(#[from] anyhow::Error),
15    /// URL parsing related errors
16    #[error(transparent)]
17    Url(#[from] url::ParseError),
18    /// JSON Serialization\Deserialization related errors
19    #[error(transparent)]
20    Json(#[from] serde_json::Error),
21    /// Integer parsing related errors
22    #[error(transparent)]
23    Int(#[from] std::num::ParseIntError),
24    /// std IO related errors
25    #[error(transparent)]
26    Io(#[from] std::io::Error),
27    /// Error parsing boolean value
28    #[error(transparent)]
29    Bool(#[from] std::str::ParseBoolError),
30    /// Invalid variable query format
31    #[error("Invalid variable query format: {0}. Expected format: key:operator:value")]
32    InvalidVariableQuery(String),
33    /// Invalid tag query format
34    #[error("Invalid tag query format: {0}. Expected format: operator:name")]
35    InvalidTagQuery(String),
36    /// Invalid query operator
37    #[error("Invalid query operator: {0}. Expected one of: ==, !=, ~=, !~=")]
38    InvalidQueryOperator(String),
39    /// Pagination error
40    #[error("Pagination error: {0}")]
41    Pagination(String),
42}