12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- use std:: fmt:: Display ;
16
-
17
15
use common_exception:: ErrorCode ;
18
16
19
17
use crate :: MetaError ;
20
18
use crate :: MetaNetworkError ;
21
- use crate :: MetaResult ;
22
19
23
20
impl From < MetaError > for ErrorCode {
24
21
fn from ( e : MetaError ) -> Self {
@@ -31,45 +28,6 @@ impl From<MetaError> for ErrorCode {
31
28
}
32
29
}
33
30
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
-
73
31
impl From < tonic:: Status > for MetaError {
74
32
fn from ( status : tonic:: Status ) -> Self {
75
33
let net_err = MetaNetworkError :: from ( status) ;
0 commit comments