Skip to main content

stac_io/
error.rs

1use thiserror::Error;
2
3/// Crate-specific error enum
4#[derive(Error, Debug)]
5#[non_exhaustive]
6pub enum Error {
7    /// An error from a [streaming search](crate::stream) backend, which produces its own error type.
8    #[error(transparent)]
9    StreamBackend(#[from] Box<dyn std::error::Error + Send + Sync>),
10
11    /// Returned when unable to read a STAC value from a path.
12    #[error("{io}: {path}")]
13    FromPath {
14        /// The [std::io::Error]
15        #[source]
16        io: std::io::Error,
17
18        /// The path.
19        path: String,
20    },
21
22    /// [http::header::InvalidHeaderName]
23    #[error(transparent)]
24    InvalidHeaderName(#[from] http::header::InvalidHeaderName),
25
26    /// [http::header::InvalidHeaderValue]
27    #[error(transparent)]
28    InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
29
30    /// [http::method::InvalidMethod]
31    #[error(transparent)]
32    InvalidMethod(#[from] http::method::InvalidMethod),
33
34    /// [tokio::task::JoinError]
35    #[error(transparent)]
36    Join(#[from] tokio::task::JoinError),
37
38    /// [std::io::Error]
39    #[error(transparent)]
40    Io(#[from] std::io::Error),
41
42    #[cfg(feature = "store")]
43    #[error(transparent)]
44    /// [object_store::Error]
45    ObjectStore(#[from] object_store::Error),
46
47    #[cfg(feature = "geoparquet")]
48    #[error(transparent)]
49    /// [parquet::errors::ParquetError]
50    Parquet(#[from] parquet::errors::ParquetError),
51
52    #[error(transparent)]
53    /// [reqwest::Error]
54    Reqwest(#[from] reqwest::Error),
55
56    #[error(transparent)]
57    /// [serde_json::Error]
58    SerdeJson(#[from] serde_json::Error),
59
60    #[error(transparent)]
61    /// [stac::Error]
62    Stac(#[from] stac::Error),
63
64    /// [std::num::TryFromIntError]
65    #[error(transparent)]
66    TryFromInt(#[from] std::num::TryFromIntError),
67
68    /// Unsupported file format.
69    #[error("unsupported format: {0}")]
70    UnsupportedFormat(String),
71
72    /// [url::ParseError]
73    #[error(transparent)]
74    UrlParse(#[from] url::ParseError),
75}