mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-20 11:32:19 +00:00
refactor error framework
Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
@@ -29,3 +29,32 @@ impl BucketMetadataError {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BucketMetadataError {
|
||||
pub fn to_u32(&self) -> u32 {
|
||||
match self {
|
||||
BucketMetadataError::TaggingNotFound => 0x01,
|
||||
BucketMetadataError::BucketPolicyNotFound => 0x02,
|
||||
BucketMetadataError::BucketObjectLockConfigNotFound => 0x03,
|
||||
BucketMetadataError::BucketLifecycleNotFound => 0x04,
|
||||
BucketMetadataError::BucketSSEConfigNotFound => 0x05,
|
||||
BucketMetadataError::BucketQuotaConfigNotFound => 0x06,
|
||||
BucketMetadataError::BucketReplicationConfigNotFound => 0x07,
|
||||
BucketMetadataError::BucketRemoteTargetNotFound => 0x08,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_u32(error: u32) -> Option<Self> {
|
||||
match error {
|
||||
0x01 => Some(BucketMetadataError::TaggingNotFound),
|
||||
0x02 => Some(BucketMetadataError::BucketPolicyNotFound),
|
||||
0x03 => Some(BucketMetadataError::BucketObjectLockConfigNotFound),
|
||||
0x04 => Some(BucketMetadataError::BucketLifecycleNotFound),
|
||||
0x05 => Some(BucketMetadataError::BucketSSEConfigNotFound),
|
||||
0x06 => Some(BucketMetadataError::BucketQuotaConfigNotFound),
|
||||
0x07 => Some(BucketMetadataError::BucketReplicationConfigNotFound),
|
||||
0x08 => Some(BucketMetadataError::BucketRemoteTargetNotFound),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user