Skip to content

Commit

Permalink
Merge pull request #20 from Scoopit/impl-error-trait
Browse files Browse the repository at this point in the history
Implement Error trait for Error struct (with the help of thiserror)
  • Loading branch information
andygrove authored Feb 19, 2024
2 parents 15a3ece + dfe1f20 commit 3f9350f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ comfy-table = "6.1.2"
datafusion = { version = "33.0", features = ["avro"] }
structopt = "0.3"
tokio = "1.19"
thiserror = "1"
30 changes: 8 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,16 @@ pub mod convert;
pub mod parquet;
pub mod utils;

#[derive(Debug)]
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
General(String),
DataFusion(DataFusionError),
Parquet(ParquetError),
IoError(std::io::Error),
}

impl From<DataFusionError> for Error {
fn from(e: DataFusionError) -> Self {
Self::DataFusion(e)
}
}

impl From<ParquetError> for Error {
fn from(e: ParquetError) -> Self {
Self::Parquet(e)
}
}

impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Self::IoError(e)
}
#[error("Data Fusion error: {0}")]
DataFusion(#[from] DataFusionError),
#[error("Parquet error: {0}")]
Parquet(#[from] ParquetError),
#[error("I/O error: {0}")]
IoError(#[from] std::io::Error),
}

#[derive(Debug)]
Expand Down

0 comments on commit 3f9350f

Please sign in to comment.