Skip to content

Commit

Permalink
Error handling update
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Aug 5, 2024
1 parent fd49e8f commit daf8dc3
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use gcloud_sdk::google_rest_apis::storage_v1::objects_api::{
StoragePeriodObjectsPeriodGetError, StoragePeriodObjectsPeriodInsertError,
StoragePeriodObjectsPeriodListError,
};
use gcloud_sdk::tonic::metadata::errors::InvalidMetadataValue;
use thiserror::Error;

Expand All @@ -15,35 +11,23 @@ pub enum AppError {
InputOutputError(#[from] std::io::Error),
#[error("Destination '{destination}' doesn't support multiple files. Trailing slash needed?")]
DestinationDoesNotSupportMultipleFiles { destination: String },
#[error("Google Cloud SDK error")]
#[error("Google Cloud REST SDK error:\n{0}")]
GoogleCloudRestSdkError(#[from] gcloud_sdk::error::Error),
#[error("Google Cloud Storage download error")]
GoogleCloudStorageGetObjectError(
#[from] gcloud_sdk::google_rest_apis::storage_v1::Error<StoragePeriodObjectsPeriodGetError>,
),
#[error("Google Cloud Storage upload error")]
GoogleCloudStorageInsertObjectError(
#[from]
gcloud_sdk::google_rest_apis::storage_v1::Error<StoragePeriodObjectsPeriodInsertError>,
),
#[error("Google Cloud Storage upload error")]
GoogleCloudStorageListObjectError(
#[from]
gcloud_sdk::google_rest_apis::storage_v1::Error<StoragePeriodObjectsPeriodListError>,
),
#[error("Google Cloud SDK error")]
#[error("Google Cloud REST SDK API error:\n{0:?}")]
GoogleCloudRestSdkApiError(Box<dyn std::fmt::Debug + Send + Sync + 'static>),
#[error("Google Cloud SDK error:\n{0}")]
GoogleCloudGrpcError(#[from] gcloud_sdk::tonic::Status),
#[error("Google Cloud invalid metadata value")]
#[error("Google Cloud invalid metadata value:\n{0}")]
GoogleCloudInvalidMetadataValue(#[from] InvalidMetadataValue),
#[error("AWS SDK error occurred")]
AwsSdkError(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
#[error("MIME error")]
#[error("MIME error:\n{0}")]
MimeError(#[from] mime::FromStrError),
#[error("HTTP client error")]
#[error("HTTP client error:\n{0}")]
HttpClientError(#[from] reqwest::Error),
#[error("Zip error")]
#[error("Zip error:\n{0}")]
ZipError(#[from] zip::result::ZipError),
#[error("CSV parser error")]
#[error("CSV parser error:\n{0}")]
CsvParserError(#[from] csv_async::Error),
#[error("Redacter config error: {message}")]
RedacterConfigError { message: String },
Expand All @@ -60,3 +44,11 @@ impl<
Self::AwsSdkError(Box::new(err))
}
}

impl<T: std::fmt::Debug + Send + Sync + 'static>
From<gcloud_sdk::google_rest_apis::storage_v1::Error<T>> for AppError
{
fn from(err: gcloud_sdk::google_rest_apis::storage_v1::Error<T>) -> Self {
Self::GoogleCloudRestSdkApiError(Box::new(err))
}
}

0 comments on commit daf8dc3

Please sign in to comment.