Commit b3f31fc 1 parent aaff133 commit b3f31fc Copy full SHA for b3f31fc
File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,22 @@ pub enum EVMError<DBError> {
152
152
Precompile ( String ) ,
153
153
}
154
154
155
+ impl < DBError > EVMError < DBError > {
156
+ /// Maps a `DBError` to a new error type using the provided closure, leaving other variants unchanged.
157
+ pub fn map_db_err < F , E > ( self , op : F ) -> EVMError < E >
158
+ where
159
+ F : FnOnce ( DBError ) -> E ,
160
+ {
161
+ match self {
162
+ Self :: Transaction ( e) => EVMError :: Transaction ( e) ,
163
+ Self :: Header ( e) => EVMError :: Header ( e) ,
164
+ Self :: Database ( e) => EVMError :: Database ( op ( e) ) ,
165
+ Self :: Precompile ( e) => EVMError :: Precompile ( e) ,
166
+ Self :: Custom ( e) => EVMError :: Custom ( e) ,
167
+ }
168
+ }
169
+ }
170
+
155
171
#[ cfg( feature = "std" ) ]
156
172
impl < DBError : std:: error:: Error + ' static > std:: error:: Error for EVMError < DBError > {
157
173
fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
You can’t perform that action at this time.
0 commit comments