@@ -16,10 +16,7 @@ mod http;
16
16
/// endpoints, use helpers like `bad_request` or `server_error` which set a
17
17
/// correct status code.
18
18
pub fn cargo_err < S : ToString + ?Sized > ( error : & S ) -> Box < dyn AppError > {
19
- Box :: new ( ConcreteAppError {
20
- description : error. to_string ( ) ,
21
- cargo_err : true ,
22
- } )
19
+ Box :: new ( http:: Ok ( error. to_string ( ) ) )
23
20
}
24
21
25
22
// The following are intended to be used for errors being sent back to the Ember
@@ -51,6 +48,9 @@ pub trait AppError: Send + fmt::Display + fmt::Debug + 'static {
51
48
}
52
49
53
50
/// Generate an HTTP response for the error
51
+ ///
52
+ /// If none is returned, the error will bubble up the middleware stack
53
+ /// where it is eventually logged and turned into a status 500 response.
54
54
fn response ( & self ) -> Option < Response > ;
55
55
56
56
/// Fallback logic for generating a cargo friendly response
@@ -222,7 +222,6 @@ impl<E: Error + Send + 'static> From<E> for Box<dyn AppError> {
222
222
#[ derive( Debug ) ]
223
223
struct ConcreteAppError {
224
224
description : String ,
225
- cargo_err : bool ,
226
225
}
227
226
228
227
impl fmt:: Display for ConcreteAppError {
@@ -242,9 +241,6 @@ impl AppError for ConcreteAppError {
242
241
fn response ( & self ) -> Option < Response > {
243
242
self . fallback_response ( )
244
243
}
245
- fn fallback_with_description_as_bad_200 ( & self ) -> bool {
246
- self . cargo_err
247
- }
248
244
}
249
245
250
246
#[ derive( Debug , Clone , Copy ) ]
@@ -325,7 +321,6 @@ impl fmt::Display for BadRequest {
325
321
pub fn internal < S : ToString + ?Sized > ( error : & S ) -> Box < dyn AppError > {
326
322
Box :: new ( ConcreteAppError {
327
323
description : error. to_string ( ) ,
328
- cargo_err : false ,
329
324
} )
330
325
}
331
326
0 commit comments