Skip to content

Commit abed122

Browse files
committed
refactor(meta/error): remove unused ToMetaError
1 parent 2645e2f commit abed122

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

src/meta/types/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ pub use meta_bytes_error::MetaBytesError;
124124
pub use meta_client_errors::MetaClientError;
125125
pub use meta_errors::MetaError;
126126
pub use meta_errors::MetaResult;
127-
pub use meta_errors_into::ToMetaError;
128127
pub use meta_forward_errors::MetaAPIError;
129128
pub use meta_forward_errors::MetaDataError;
130129
pub use meta_forward_errors::MetaDataReadError;

src/meta/types/src/meta_errors_into.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::fmt::Display;
16-
1715
use common_exception::ErrorCode;
1816

1917
use crate::MetaError;
2018
use crate::MetaNetworkError;
21-
use crate::MetaResult;
2219

2320
impl From<MetaError> for ErrorCode {
2421
fn from(e: MetaError) -> Self {
@@ -31,45 +28,6 @@ impl From<MetaError> for ErrorCode {
3128
}
3229
}
3330

34-
pub trait ToMetaError<T, E, CtxFn>
35-
where E: Display + Send + Sync + 'static
36-
{
37-
/// Wrap the error value with MetaError. It is lazily evaluated:
38-
/// only when an error does occur.
39-
///
40-
/// `err_code_fn` is one of the MetaError builder function such as `MetaError::Ok`.
41-
/// `context_fn` builds display_text for the MetaError.
42-
fn map_error_to_meta_error<ErrFn, D>(
43-
self,
44-
err_code_fn: ErrFn,
45-
context_fn: CtxFn,
46-
) -> MetaResult<T>
47-
where
48-
ErrFn: FnOnce(String) -> MetaError,
49-
D: Display,
50-
CtxFn: FnOnce() -> D;
51-
}
52-
53-
impl<T, E, CtxFn> ToMetaError<T, E, CtxFn> for std::result::Result<T, E>
54-
where E: Display + Send + Sync + 'static
55-
{
56-
fn map_error_to_meta_error<ErrFn, D>(
57-
self,
58-
make_exception: ErrFn,
59-
context_fn: CtxFn,
60-
) -> MetaResult<T>
61-
where
62-
ErrFn: FnOnce(String) -> MetaError,
63-
D: Display,
64-
CtxFn: FnOnce() -> D,
65-
{
66-
self.map_err(|error| {
67-
let err_text = format!("{}, cause: {}", context_fn(), error);
68-
make_exception(err_text)
69-
})
70-
}
71-
}
72-
7331
impl From<tonic::Status> for MetaError {
7432
fn from(status: tonic::Status) -> Self {
7533
let net_err = MetaNetworkError::from(status);

0 commit comments

Comments
 (0)