@@ -6,8 +6,13 @@ use std::fs::{self, read_to_string, File};
6
6
use std:: io:: Read ;
7
7
use std:: path:: { Path , PathBuf } ;
8
8
use std:: process:: Stdio ;
9
+ use thiserror:: Error ;
9
10
use tokio:: process:: Command ;
10
11
12
+ #[ derive( Error , Debug , PartialEq , Eq ) ]
13
+ #[ error( "Unrecoverable devnet error: `{0}`" ) ]
14
+ pub struct UnrecoverableDevnetError ( pub String ) ;
15
+
11
16
#[ derive( Debug , Clone , Default ) ]
12
17
pub struct Devnet {
13
18
artifacts_dir : PathBuf ,
@@ -211,7 +216,9 @@ impl Devnet {
211
216
. with_context ( || "Error while starting the devnet" ) ?;
212
217
match status. code ( ) {
213
218
Some ( 0 ) => Ok ( ( ) ) ,
214
- Some ( code) => Err ( anyhow ! ( "Run devnet exited with status code: {code}" ) ) ,
219
+ Some ( code) => Err ( anyhow ! ( UnrecoverableDevnetError ( format!(
220
+ "Run devnet exited with status code: {code}"
221
+ ) ) ) ) ,
215
222
None => Err ( anyhow ! ( "Run devnet terminated by signal" ) ) ,
216
223
}
217
224
}
@@ -258,7 +265,9 @@ impl Devnet {
258
265
. with_context ( || "Error while delegating stakes to the pools" ) ?;
259
266
match status. code ( ) {
260
267
Some ( 0 ) => Ok ( ( ) ) ,
261
- Some ( code) => Err ( anyhow ! ( "Delegating stakes exited with status code: {code}" ) ) ,
268
+ Some ( code) => Err ( anyhow ! ( UnrecoverableDevnetError ( format!(
269
+ "Delegating stakes exited with status code: {code}"
270
+ ) ) ) ) ,
262
271
None => Err ( anyhow ! ( "Delegating stakes terminated by signal" ) ) ,
263
272
}
264
273
}
@@ -282,9 +291,9 @@ impl Devnet {
282
291
. with_context ( || "Error while writing era marker on chain" ) ?;
283
292
match status. code ( ) {
284
293
Some ( 0 ) => Ok ( ( ) ) ,
285
- Some ( code) => Err ( anyhow ! (
294
+ Some ( code) => Err ( anyhow ! ( UnrecoverableDevnetError ( format! (
286
295
"Write era marker on chain exited with status code: {code}"
287
- ) ) ,
296
+ ) ) ) ) ,
288
297
None => Err ( anyhow ! ( "Write era marker on chain terminated by signal" ) ) ,
289
298
}
290
299
}
@@ -308,9 +317,9 @@ impl Devnet {
308
317
. with_context ( || "Error while to transferring funds on chain" ) ?;
309
318
match status. code ( ) {
310
319
Some ( 0 ) => Ok ( ( ) ) ,
311
- Some ( code) => Err ( anyhow ! (
320
+ Some ( code) => Err ( anyhow ! ( UnrecoverableDevnetError ( format! (
312
321
"Transfer funds on chain exited with status code: {code}"
313
- ) ) ,
322
+ ) ) ) ) ,
314
323
None => Err ( anyhow ! ( "Transfer funds on chain terminated by signal" ) ) ,
315
324
}
316
325
}
0 commit comments