iceberg_rust_spec/
error.rs

1/*!
2Error type for iceberg
3*/
4
5use thiserror::Error;
6
7#[derive(Error, Debug)]
8/// Iceberg error
9pub enum Error {
10    /// Invalid format
11    #[error("{0} doesn't have the right format")]
12    InvalidFormat(String),
13    /// Type error
14    #[error("Value {0} doesn't have the {1} type.")]
15    Type(String, String),
16    /// Schema error
17    #[error("Column {0} not in schema {1}.")]
18    ColumnNotInSchema(String, String),
19    /// Conversion error
20    #[error("Failed to convert {0} to {1}.")]
21    Conversion(String, String),
22    /// Not found
23    #[error("{0} not found.")]
24    NotFound(String),
25    /// Not supported
26    #[error("Feature {0} is not supported.")]
27    NotSupported(String),
28    /// Avro error
29    #[error(transparent)]
30    Avro(Box<apache_avro::Error>),
31    /// Serde json
32    #[error(transparent)]
33    JSONSerde(#[from] serde_json::Error),
34    /// Chrono parse
35    #[error(transparent)]
36    Chrono(#[from] chrono::ParseError),
37    /// Chrono parse
38    #[error(transparent)]
39    Uuid(#[from] uuid::Error),
40    /// Io error
41    #[error(transparent)]
42    IO(#[from] std::io::Error),
43    /// Try from slice error
44    #[error(transparent)]
45    TryFromSlice(#[from] std::array::TryFromSliceError),
46    /// Try from int error
47    #[error(transparent)]
48    TryFromInt(#[from] std::num::TryFromIntError),
49    /// Utf8 error
50    #[error(transparent)]
51    UTF8(#[from] std::str::Utf8Error),
52    /// from utf8 error
53    #[error(transparent)]
54    FromUTF8(#[from] std::string::FromUtf8Error),
55    /// parse int error
56    #[error(transparent)]
57    ParseInt(#[from] std::num::ParseIntError),
58    /// derive builder
59    #[error(transparent)]
60    DeriveBuilder(#[from] derive_builder::UninitializedFieldError),
61}
62
63impl From<apache_avro::Error> for Error {
64    fn from(err: apache_avro::Error) -> Self {
65        Error::Avro(Box::new(err))
66    }
67}