Skip to main content

superstac_core/
errors.rs

1use thiserror::Error;
2
3#[derive(Error, Debug, PartialEq)]
4pub enum StorageError {
5    #[error("failed to read/write storage: {0}")]
6    Io(String),
7
8    #[error("serialization error: {0}")]
9    Serde(String),
10
11    #[error("catalog id '{0}' already exists (set auto_fix_duplicate_catalog_id=true or use a unique id)")]
12    CatalogIdAlreadyExist(String),
13
14    #[error("provider id '{0}' already exists (set auto_fix_duplicate_provider_id=true or use a unique id)")]
15    CatalogProviderIdAlreadyExist(String),
16
17    #[error("provider '{0}' does not exist")]
18    CatalogProviderDoesNotExist(String),
19
20    #[error("catalog '{0}' does not exist")]
21    CatalogDoesNotExist(String),
22
23    #[error("catalogs not found: {0:?}")]
24    CatalogsNotFound(Vec<String>),
25
26    #[error("providers not found: {0:?}")]
27    ProvidersNotFound(Vec<String>),
28
29    #[error("{0}")]
30    CatalogAlreadyHasProvider(String),
31}
32
33#[derive(Error, Debug, PartialEq)]
34pub enum ValidationError {
35    #[error("invalid url: {0}")]
36    InvalidUrl(String),
37    #[error("missing field: {0}")]
38    MissingField(String),
39    #[error("invalid identifier: {0}")]
40    InvalidIdentifier(String),
41}
42
43#[derive(Debug, Error, PartialEq)]
44pub enum SuperSTACError {
45    #[error("validation: {0}")]
46    Validation(#[from] ValidationError),
47    #[error("storage: {0}")]
48    Storage(#[from] StorageError),
49    #[error("search failed: {0}")]
50    SearchFailed(String),
51}