@@ -42,6 +42,7 @@ use polkadot_primitives::v1::{
42
42
SignedAvailabilityBitfield ,
43
43
} ;
44
44
use std:: { collections:: HashMap , convert:: TryFrom , pin:: Pin } ;
45
+ use thiserror:: Error ;
45
46
46
47
struct ProvisioningJob {
47
48
relay_parent : Hash ,
@@ -115,19 +116,25 @@ impl TryFrom<AllMessages> for FromJob {
115
116
}
116
117
}
117
118
118
- #[ derive( Debug , derive_more :: From ) ]
119
+ #[ derive( Debug , Error ) ]
119
120
enum Error {
120
- #[ from]
121
- Sending ( mpsc:: SendError ) ,
122
- #[ from]
121
+ #[ error( transparent) ]
123
122
Util ( util:: Error ) ,
124
- #[ from]
123
+
124
+ #[ error( transparent) ]
125
125
OneshotRecv ( oneshot:: Canceled ) ,
126
- #[ from]
126
+
127
+ #[ error( transparent) ]
127
128
ChainApi ( ChainApiError ) ,
128
- #[ from]
129
+
130
+ #[ error( transparent) ]
129
131
Runtime ( RuntimeApiError ) ,
130
- OneshotSend ,
132
+
133
+ #[ error( "Failed to send message to ChainAPI" ) ]
134
+ ChainApiMessageSend ( #[ source] mpsc:: SendError ) ,
135
+
136
+ #[ error( "Failed to send return message with Inherents" ) ]
137
+ InherentDataReturnChannel ( #[ source] mpsc:: SendError ) ,
131
138
}
132
139
133
140
impl JobTrait for ProvisioningJob {
@@ -299,7 +306,7 @@ async fn send_inherent_data(
299
306
300
307
return_sender
301
308
. send ( ( bitfields, candidates) )
302
- . map_err ( |_ | Error :: OneshotSend ) ?;
309
+ . map_err ( |e | Error :: InherentDataReturnChannel ( e ) ) ?;
303
310
Ok ( ( ) )
304
311
}
305
312
@@ -423,7 +430,7 @@ async fn get_block_number_under_construction(
423
430
tx,
424
431
) ) )
425
432
. await
426
- . map_err ( |_ | Error :: OneshotSend ) ?;
433
+ . map_err ( |e | Error :: ChainApiMessageSend ( e ) ) ?;
427
434
match rx. await ? {
428
435
Ok ( Some ( n) ) => Ok ( n + 1 ) ,
429
436
Ok ( None ) => Ok ( 0 ) ,
@@ -801,7 +808,7 @@ mod tests {
801
808
Delay :: new ( std:: time:: Duration :: from_millis ( 50 ) ) . await ;
802
809
let result = select_candidates ( & [ ] , & [ ] , & [ ] , Default :: default ( ) , & mut tx) . await ;
803
810
println ! ( "{:?}" , result) ;
804
- assert ! ( std:: matches!( result, Err ( Error :: OneshotSend ) ) ) ;
811
+ assert ! ( std:: matches!( result, Err ( Error :: ChainApiMessageSend ( _ ) ) ) ) ;
805
812
} ;
806
813
807
814
test_harness ( overseer, test) ;
0 commit comments