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    /// table metadata builder
59    #[error(transparent)]
60    TableMetadataBuilder(#[from] crate::spec::table_metadata::TableMetadataBuilderError),
61    /// view metadata builder
62    #[error(transparent)]
63    ViewMetadataBuilder(#[from] crate::spec::view_metadata::GeneralViewMetadataBuilderError),
64    /// version builder
65    #[error(transparent)]
66    VersionBuilder(#[from] crate::spec::view_metadata::VersionBuilderError),
67    /// manifest builder
68    #[error(transparent)]
69    ManifestEntryBuilder(#[from] crate::spec::manifest::ManifestEntryBuilderError),
70    /// datafile builder
71    #[error(transparent)]
72    DatafileBuilder(#[from] crate::spec::manifest::DataFileBuilderError),
73    /// snapshot builder
74    #[error(transparent)]
75    SnapshotBuilder(#[from] crate::spec::snapshot::SnapshotBuilderError),
76    /// structype builder
77    #[error(transparent)]
78    StructTypeBuilder(#[from] crate::spec::types::StructTypeBuilderError),
79    /// partition spec builder
80    #[error(transparent)]
81    PartitionSpec(#[from] crate::spec::partition::PartitionSpecBuilderError),
82}
83
84impl From<apache_avro::Error> for Error {
85    fn from(err: apache_avro::Error) -> Self {
86        Error::Avro(Box::new(err))
87    }
88}