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#[derive(Error, Debug)]
11pub enum ToolError {
12 #[error(transparent)]
14 General(#[from] anyhow::Error),
15 #[error(transparent)]
17 Url(#[from] url::ParseError),
18 #[error(transparent)]
20 Json(#[from] serde_json::Error),
21 #[error(transparent)]
23 Int(#[from] std::num::ParseIntError),
24 #[error(transparent)]
26 Io(#[from] std::io::Error),
27 #[error(transparent)]
29 Bool(#[from] std::str::ParseBoolError),
30 #[error("Invalid variable query format: {0}. Expected format: key:operator:value")]
32 InvalidVariableQuery(String),
33 #[error("Invalid tag query format: {0}. Expected format: operator:name")]
35 InvalidTagQuery(String),
36 #[error("Invalid query operator: {0}. Expected one of: ==, !=, ~=, !~=")]
38 InvalidQueryOperator(String),
39 #[error("Pagination error: {0}")]
41 Pagination(String),
42}