1use thiserror::Error;
5
6pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, Error)]
9pub enum Error {
10 #[error("I/O error: {0}")]
11 Io(#[from] std::io::Error),
12
13 #[error("malformed input: {0}")]
14 Malformed(String),
15
16 #[error("unsupported feature: {0}")]
17 Unsupported(String),
18
19 #[error("schema mismatch: {0}")]
20 Schema(String),
21
22 #[error("layer not found: {0}")]
23 LayerNotFound(String),
24
25 #[error("{0}")]
26 Other(String),
27}
28
29impl Error {
30 pub fn malformed(msg: impl Into<String>) -> Self {
31 Self::Malformed(msg.into())
32 }
33
34 pub fn unsupported(msg: impl Into<String>) -> Self {
35 Self::Unsupported(msg.into())
36 }
37
38 pub fn schema(msg: impl Into<String>) -> Self {
39 Self::Schema(msg.into())
40 }
41}