@@ -18,6 +18,7 @@ use tonic::Status;
18
18
use crate :: AppError ;
19
19
use crate :: MetaAPIError ;
20
20
use crate :: MetaClientError ;
21
+ use crate :: MetaError ;
21
22
use crate :: MetaNetworkError ;
22
23
use crate :: MetaStorageError ;
23
24
@@ -42,44 +43,50 @@ pub enum KVAppError {
42
43
#[ error( transparent) ]
43
44
AppError ( #[ from] AppError ) ,
44
45
45
- // ---
46
- // --- Local embedded meta-store errors ---
47
- // ---
48
- /// Errors occurred when accessing local embedded meta-store.
49
- #[ error( transparent) ]
50
- StorageError ( #[ from] MetaStorageError ) ,
51
-
52
- // ---
53
- // --- Remote meta-store service errors ---
54
- // ---
55
- /// Errors when invoking remote meta-service RPC.
56
- #[ error( transparent) ]
57
- NetworkError ( #[ from] MetaNetworkError ) ,
58
-
59
- /// Errors when creating or accessing the client to a remote meta-service.
60
- #[ error( transparent) ]
61
- ClientError ( #[ from] MetaClientError ) ,
62
-
63
- /// Remote error occurred when meta-service handling a request
64
- #[ error( transparent) ]
65
- APIError ( #[ from] MetaAPIError ) ,
46
+ #[ error( "fail to access meta-store: {0}" ) ]
47
+ MetaError ( #[ from] MetaError ) ,
66
48
}
67
49
68
50
impl From < KVAppError > for ErrorCode {
69
51
fn from ( e : KVAppError ) -> Self {
70
52
match e {
71
53
KVAppError :: AppError ( app_err) => app_err. into ( ) ,
72
- KVAppError :: NetworkError ( net_err) => net_err. into ( ) ,
73
- KVAppError :: StorageError ( sto_err) => sto_err. into ( ) ,
74
- KVAppError :: ClientError ( ce) => ce. into ( ) ,
75
- KVAppError :: APIError ( e) => e. into ( ) ,
54
+ KVAppError :: MetaError ( meta_err) => meta_err. into ( ) ,
76
55
}
77
56
}
78
57
}
79
58
80
59
impl From < Status > for KVAppError {
81
60
fn from ( s : Status ) -> Self {
82
- let net_err = MetaNetworkError :: from ( s) ;
83
- Self :: NetworkError ( net_err)
61
+ let meta_err = MetaError :: from ( s) ;
62
+ Self :: MetaError ( meta_err)
63
+ }
64
+ }
65
+
66
+ impl From < MetaStorageError > for KVAppError {
67
+ fn from ( e : MetaStorageError ) -> Self {
68
+ let meta_err = MetaError :: from ( e) ;
69
+ Self :: MetaError ( meta_err)
70
+ }
71
+ }
72
+
73
+ impl From < MetaClientError > for KVAppError {
74
+ fn from ( e : MetaClientError ) -> Self {
75
+ let meta_err = MetaError :: from ( e) ;
76
+ Self :: MetaError ( meta_err)
77
+ }
78
+ }
79
+
80
+ impl From < MetaNetworkError > for KVAppError {
81
+ fn from ( e : MetaNetworkError ) -> Self {
82
+ let meta_err = MetaError :: from ( e) ;
83
+ Self :: MetaError ( meta_err)
84
+ }
85
+ }
86
+
87
+ impl From < MetaAPIError > for KVAppError {
88
+ fn from ( e : MetaAPIError ) -> Self {
89
+ let meta_err = MetaError :: from ( e) ;
90
+ Self :: MetaError ( meta_err)
84
91
}
85
92
}
0 commit comments