From b585f30204441a78a7050106ade518853b686b6f Mon Sep 17 00:00:00 2001 From: Abhi Agarwal Date: Fri, 14 Jun 2024 12:00:31 -0400 Subject: [PATCH] chore: implement error handling for object_store --- parquet/src/arrow/async_reader/store.rs | 10 +++------- parquet/src/errors.rs | 7 +++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/parquet/src/arrow/async_reader/store.rs b/parquet/src/arrow/async_reader/store.rs index 293b91aea3ba..77c00e91a3aa 100644 --- a/parquet/src/arrow/async_reader/store.rs +++ b/parquet/src/arrow/async_reader/store.rs @@ -25,7 +25,7 @@ use futures::{FutureExt, TryFutureExt}; use object_store::{ObjectMeta, ObjectStore}; use crate::arrow::async_reader::{AsyncFileReader, MetadataLoader}; -use crate::errors::{ParquetError, Result}; +use crate::errors::Result; use crate::file::metadata::ParquetMetaData; /// Reads Parquet files in object storage using [`ObjectStore`]. @@ -105,7 +105,7 @@ impl AsyncFileReader for ParquetObjectReader { fn get_bytes(&mut self, range: Range) -> BoxFuture<'_, Result> { self.store .get_range(&self.meta.location, range) - .map_err(|e| ParquetError::General(format!("AsyncChunkReader::get_bytes error: {e}"))) + .map_err(|e| e.into()) .boxed() } @@ -117,11 +117,7 @@ impl AsyncFileReader for ParquetObjectReader { self.store .get_ranges(&self.meta.location, &ranges) .await - .map_err(|e| { - ParquetError::General(format!( - "ParquetObjectReader::get_byte_ranges error: {e}" - )) - }) + .map_err(|e| e.into()) } .boxed() } diff --git a/parquet/src/errors.rs b/parquet/src/errors.rs index 0b70266b3012..a242c9768514 100644 --- a/parquet/src/errors.rs +++ b/parquet/src/errors.rs @@ -112,6 +112,13 @@ impl From for ParquetError { } } +#[cfg(feature = "object_store")] +impl From for ParquetError { + fn from(e: object_store::Error) -> ParquetError { + ParquetError::External(Box::new(e)) + } +} + /// A specialized `Result` for Parquet errors. pub type Result = result::Result;