mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-13 08:36:54 +00:00
refactor error framework
Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
+11
-6
@@ -14,6 +14,7 @@ pub const FORMAT_CONFIG_FILE: &str = "format.json";
|
||||
pub const STORAGE_FORMAT_FILE: &str = "xl.meta";
|
||||
pub const STORAGE_FORMAT_FILE_BACKUP: &str = "xl.meta.bkp";
|
||||
|
||||
use crate::utils::proto_err_to_err;
|
||||
use crate::{
|
||||
erasure::Writer,
|
||||
error::{Error, Result},
|
||||
@@ -1109,9 +1110,11 @@ impl Writer for RemoteFileWriter {
|
||||
if resp.success {
|
||||
info!("write stream success");
|
||||
} else {
|
||||
let error_info = resp.error_info.unwrap_or("".to_string());
|
||||
info!("write stream failed: {}", error_info);
|
||||
return Err(Error::from_string(error_info));
|
||||
return if let Some(err) = &resp.error {
|
||||
Err(proto_err_to_err(err))
|
||||
} else {
|
||||
Err(Error::from_string(""))
|
||||
};
|
||||
}
|
||||
} else {
|
||||
let error_info = "can not get response";
|
||||
@@ -1287,9 +1290,11 @@ impl Reader for RemoteFileReader {
|
||||
|
||||
Ok(resp.read_size.try_into().unwrap())
|
||||
} else {
|
||||
let error_info = resp.error_info.unwrap_or("".to_string());
|
||||
info!("read at stream failed: {}", error_info);
|
||||
Err(Error::from_string(error_info))
|
||||
return if let Some(err) = &resp.error {
|
||||
Err(proto_err_to_err(err))
|
||||
} else {
|
||||
Err(Error::from_string(""))
|
||||
};
|
||||
}
|
||||
} else {
|
||||
let error_info = "can not get response";
|
||||
|
||||
Reference in New Issue
Block a user