use arrow::error::ArrowError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("{0} doesn't have the right format")]
InvalidFormat(String),
#[error("Value {0} doesn't have the {1} type.")]
Type(String, String),
#[error("Column {0} not in schema {1}.")]
Schema(String, String),
#[error("Failed to convert {0} to {1}.")]
Conversion(String, String),
#[error("{0} {1} not found.")]
NotFound(String, String),
#[error("Feature {0} is not supported.")]
NotSupported(String),
#[error(transparent)]
Iceberg(#[from] iceberg_rust_spec::error::Error),
#[error(transparent)]
Arrow(#[from] arrow::error::ArrowError),
#[error(transparent)]
Parquet(#[from] parquet::errors::ParquetError),
#[error(transparent)]
Avro(#[from] apache_avro::Error),
#[error(transparent)]
Thrift(#[from] thrift::Error),
#[error(transparent)]
SQLParser(#[from] sqlparser::parser::ParserError),
#[error(transparent)]
JSONSerde(#[from] serde_json::Error),
#[error(transparent)]
Uuid(#[from] uuid::Error),
#[error(transparent)]
Url(#[from] url::ParseError),
#[error(transparent)]
IO(#[from] std::io::Error),
#[error(transparent)]
FuturesChannel(#[from] futures::channel::mpsc::SendError),
#[error(transparent)]
ObjectStore(#[from] object_store::Error),
#[error(transparent)]
TryFromSlice(#[from] std::array::TryFromSliceError),
#[error(transparent)]
TryFromInt(#[from] std::num::TryFromIntError),
#[error(transparent)]
UTF8(#[from] std::str::Utf8Error),
#[error(transparent)]
FromUTF8(#[from] std::string::FromUtf8Error),
#[error(transparent)]
ParseInt(#[from] std::num::ParseIntError),
#[error(transparent)]
TableMetadataBuilder(
#[from] iceberg_rust_spec::spec::table_metadata::TableMetadataBuilderError,
),
#[error(transparent)]
ViewMetadataBuilder(
#[from] iceberg_rust_spec::spec::view_metadata::GeneralViewMetadataBuilderError,
),
#[error(transparent)]
VersionBuilder(#[from] iceberg_rust_spec::spec::view_metadata::VersionBuilderError),
#[error(transparent)]
CreateTableBuilder(#[from] crate::catalog::create::CreateTableBuilderError),
#[error(transparent)]
CreateViewBuilder(#[from] crate::catalog::create::CreateViewBuilderError),
#[error(transparent)]
CreateMaterializedViewBuilder(
#[from] crate::catalog::create::CreateMaterializedViewBuilderError,
),
}
impl From<Error> for ArrowError {
fn from(value: Error) -> Self {
ArrowError::from_external_error(Box::new(value))
}
}