File tree Expand file tree Collapse file tree 3 files changed +8
-27
lines changed Expand file tree Collapse file tree 3 files changed +8
-27
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,7 @@ All notable changes to this project are documented in this file.
12
12
- ** deps** : update rust crate redis to 0.31 ([ #555 ] ( https://github.com/geofmureithi/apalis/pull/555 ) )
13
13
- ** deps** : update rust crate sentry-core to 0.38.0 ([ #569 ] ( https://github.com/geofmureithi/apalis/pull/569 ) )
14
14
- ** deps** : update rust crate criterion to 0.6.0 ([ #574 ] ( https://github.com/geofmureithi/apalis/pull/574 ) )
15
-
16
-
17
- ## Fixed
18
-
15
+ - ** error-handling** : ease the error type that is returned by a worker function ([ #577 ] ( https://github.com/geofmureithi/apalis/pull/577 ) )
19
16
- ** PostgresStorage** : fix type error when updating jobs ([ #539 ] ( https://github.com/geofmureithi/apalis/issues/539 ) )
20
17
21
18
## [ 0.7.1] ( https://github.com/geofmureithi/apalis/releases/tag/v0.7.1 )
Original file line number Diff line number Diff line change @@ -29,18 +29,6 @@ async fn produce_jobs(storage: &SqliteStorage<Email>) {
29
29
}
30
30
}
31
31
32
- #[ derive( thiserror:: Error , Debug ) ]
33
- pub enum ServiceError {
34
- #[ error( "data store disconnected" ) ]
35
- Disconnect ( #[ from] std:: io:: Error ) ,
36
- #[ error( "the data for key `{0}` is not available" ) ]
37
- Redaction ( String ) ,
38
- #[ error( "invalid header (expected {expected:?}, found {found:?})" ) ]
39
- InvalidHeader { expected : String , found : String } ,
40
- #[ error( "unknown data store error" ) ]
41
- Unknown ,
42
- }
43
-
44
32
#[ derive( thiserror:: Error , Debug ) ]
45
33
pub enum PanicError {
46
34
#[ error( "{0}" ) ]
@@ -54,7 +42,7 @@ async fn send_email(
54
42
svc : Data < EmailService > ,
55
43
worker : Worker < Context > ,
56
44
cache : Data < ValidEmailCache > ,
57
- ) -> Result < ( ) , ServiceError > {
45
+ ) -> Result < ( ) , BoxDynError > {
58
46
info ! ( "Job started in worker {:?}" , worker. id( ) ) ;
59
47
let cache_clone = cache. clone ( ) ;
60
48
let email_to = email. to . clone ( ) ;
Original file line number Diff line number Diff line change 1
- use std:: { any :: Any , fmt:: Debug , sync:: Arc } ;
1
+ use std:: { fmt:: Debug , sync:: Arc } ;
2
2
3
3
use crate :: {
4
- error:: Error ,
4
+ error:: { BoxDynError , Error } ,
5
5
task:: { attempt:: Attempt , task_id:: TaskId } ,
6
6
} ;
7
7
@@ -133,21 +133,17 @@ impl IntoResponse for bool {
133
133
}
134
134
}
135
135
136
- impl < T : Any , E : std:: error:: Error + Sync + Send + ' static + Any > IntoResponse
137
- for std:: result:: Result < T , E >
138
- {
136
+ impl < T , E : Into < BoxDynError > > IntoResponse for std:: result:: Result < T , E > {
139
137
type Result = Result < T , Error > ;
140
138
fn into_response ( self ) -> Result < T , Error > {
141
139
match self {
142
140
Ok ( value) => Ok ( value) ,
143
141
Err ( e) => {
144
- // Try to downcast the error to see if it is already of type `Error`
145
- if let Some ( custom_error) =
146
- ( & e as & ( dyn std:: error:: Error + ' static ) ) . downcast_ref :: < Error > ( )
147
- {
142
+ let e = e. into ( ) ;
143
+ if let Some ( custom_error) = e. downcast_ref :: < Error > ( ) {
148
144
return Err ( custom_error. clone ( ) ) ;
149
145
}
150
- Err ( Error :: Failed ( Arc :: new ( Box :: new ( e ) ) ) )
146
+ Err ( Error :: Failed ( Arc :: new ( e ) ) )
151
147
}
152
148
}
153
149
}
You can’t perform that action at this time.
0 commit comments