mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 14:23:13 +00:00
Merge pull request #503 from rustfs/refactor/unify-bucket-metadata-errors
refactor(ecstore): simplify bucket metadata error handling by using C…
This commit is contained in:
+17
-6
@@ -2,6 +2,7 @@ use s3s::{S3Error, S3ErrorCode};
|
||||
|
||||
use rustfs_utils::path::decode_dir_object;
|
||||
|
||||
use crate::bucket::error::BucketMetadataError;
|
||||
use crate::disk::error::DiskError;
|
||||
|
||||
pub type Error = StorageError;
|
||||
@@ -166,9 +167,6 @@ pub enum StorageError {
|
||||
#[error("first disk wait")]
|
||||
FirstDiskWait,
|
||||
|
||||
#[error("Bucket policy not found")]
|
||||
BucketPolicyNotFound,
|
||||
|
||||
#[error("Io error: {0}")]
|
||||
Io(std::io::Error),
|
||||
}
|
||||
@@ -257,6 +255,22 @@ impl From<StorageError> for DiskError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BucketMetadataError> for Error {
|
||||
fn from(e: BucketMetadataError) -> Self {
|
||||
match e {
|
||||
BucketMetadataError::TaggingNotFound => Error::ConfigNotFound,
|
||||
BucketMetadataError::BucketPolicyNotFound => Error::ConfigNotFound,
|
||||
BucketMetadataError::BucketObjectLockConfigNotFound => Error::ConfigNotFound,
|
||||
BucketMetadataError::BucketLifecycleNotFound => Error::ConfigNotFound,
|
||||
BucketMetadataError::BucketSSEConfigNotFound => Error::ConfigNotFound,
|
||||
BucketMetadataError::BucketQuotaConfigNotFound => Error::ConfigNotFound,
|
||||
BucketMetadataError::BucketReplicationConfigNotFound => Error::ConfigNotFound,
|
||||
BucketMetadataError::BucketRemoteTargetNotFound => Error::ConfigNotFound,
|
||||
_ => Error::other(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for StorageError {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
match e.downcast::<StorageError>() {
|
||||
@@ -381,7 +395,6 @@ impl Clone for StorageError {
|
||||
StorageError::FirstDiskWait => StorageError::FirstDiskWait,
|
||||
StorageError::TooManyOpenFiles => StorageError::TooManyOpenFiles,
|
||||
StorageError::NoHealRequired => StorageError::NoHealRequired,
|
||||
StorageError::BucketPolicyNotFound => StorageError::BucketPolicyNotFound,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -444,7 +457,6 @@ impl StorageError {
|
||||
StorageError::ConfigNotFound => 0x35,
|
||||
StorageError::TooManyOpenFiles => 0x36,
|
||||
StorageError::NoHealRequired => 0x37,
|
||||
StorageError::BucketPolicyNotFound => 0x38,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,7 +521,6 @@ impl StorageError {
|
||||
0x35 => Some(StorageError::ConfigNotFound),
|
||||
0x36 => Some(StorageError::TooManyOpenFiles),
|
||||
0x37 => Some(StorageError::NoHealRequired),
|
||||
0x38 => Some(StorageError::BucketPolicyNotFound),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user