@@ -44,6 +44,11 @@ async fn catch_handle<Fut, T, F>(name: Option<&str>, run: F) -> Option<T>
44
44
. ok ( )
45
45
}
46
46
47
+ pub ( crate ) fn error_ref < ' r > ( error_ptr : & ' r mut Option < Box < dyn TypedError < ' r > + ' r > > )
48
+ -> Option < & ' r dyn TypedError < ' r > > {
49
+ error_ptr. as_ref ( ) . map ( |b| b. as_ref ( ) )
50
+ }
51
+
47
52
impl Rocket < Orbit > {
48
53
/// Preprocess the request for Rocket things. Currently, this means:
49
54
///
@@ -112,21 +117,21 @@ impl Rocket<Orbit> {
112
117
Outcome :: Success ( response) => response,
113
118
Outcome :: Error ( ( status, error) ) => {
114
119
* error_ptr = error;
115
- self . dispatch_error ( status, request, error_ptr . as_ref ( ) . map ( |b| b . as_ref ( ) ) ) . await
120
+ self . dispatch_error ( status, request, error_ref ( error_ptr ) ) . await
116
121
} ,
117
122
Outcome :: Forward ( ( _, status, error) ) => {
118
123
* error_ptr = error;
119
- self . dispatch_error ( status, request, error_ptr . as_ref ( ) . map ( |b| b . as_ref ( ) ) ) . await
124
+ self . dispatch_error ( status, request, error_ref ( error_ptr ) ) . await
120
125
} ,
121
126
}
122
127
}
123
128
Outcome :: Forward ( ( _, status, error) ) => {
124
129
* error_ptr = error;
125
- self . dispatch_error ( status, request, error_ptr . as_ref ( ) . map ( |b| b . as_ref ( ) ) ) . await
130
+ self . dispatch_error ( status, request, error_ref ( error_ptr ) ) . await
126
131
} ,
127
132
Outcome :: Error ( ( status, error) ) => {
128
133
* error_ptr = error;
129
- self . dispatch_error ( status, request, error_ptr . as_ref ( ) . map ( |b| b . as_ref ( ) ) ) . await
134
+ self . dispatch_error ( status, request, error_ref ( error_ptr ) ) . await
130
135
} ,
131
136
} ;
132
137
@@ -289,7 +294,11 @@ impl Rocket<Orbit> {
289
294
let mut counter = 0 ;
290
295
// Matches error [.source ...] type
291
296
while error_copy. is_some ( ) && counter < 5 {
292
- if let Some ( catcher) = self . router . catch ( status, req, error_copy. map ( |e| e. trait_obj_typeid ( ) ) ) {
297
+ if let Some ( catcher) = self . router . catch (
298
+ status,
299
+ req,
300
+ error_copy. map ( |e| e. trait_obj_typeid ( ) )
301
+ ) {
293
302
return self . invoke_specific_catcher ( catcher, status, error_copy, req) . await ;
294
303
}
295
304
error_copy = error_copy. and_then ( |e| e. source ( ) ) ;
@@ -303,7 +312,11 @@ impl Rocket<Orbit> {
303
312
let mut counter = 0 ;
304
313
// Matches error [.source ...] type, and any status
305
314
while error_copy. is_some ( ) && counter < 5 {
306
- if let Some ( catcher) = self . router . catch_any ( status, req, error_copy. map ( |e| e. trait_obj_typeid ( ) ) ) {
315
+ if let Some ( catcher) = self . router . catch_any (
316
+ status,
317
+ req,
318
+ error_copy. map ( |e| e. trait_obj_typeid ( ) )
319
+ ) {
307
320
return self . invoke_specific_catcher ( catcher, status, error_copy, req) . await ;
308
321
}
309
322
error_copy = error_copy. and_then ( |e| e. source ( ) ) ;
0 commit comments