Skip to content

Commit c7a9802

Browse files
committed
feat: return dedicated error when devnet operations fails
1 parent 44004bf commit c7a9802

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
mod runner;
22

3-
pub use runner::{Devnet, DevnetBootstrapArgs, DevnetTopology, PoolNode};
3+
pub use runner::{Devnet, DevnetBootstrapArgs, DevnetTopology, PoolNode, UnrecoverableDevnetError};

mithril-test-lab/mithril-end-to-end/src/devnet/runner.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ use std::fs::{self, read_to_string, File};
66
use std::io::Read;
77
use std::path::{Path, PathBuf};
88
use std::process::Stdio;
9+
use thiserror::Error;
910
use tokio::process::Command;
1011

12+
#[derive(Error, Debug, PartialEq, Eq)]
13+
#[error("Unrecoverable devnet error: `{0}`")]
14+
pub struct UnrecoverableDevnetError(pub String);
15+
1116
#[derive(Debug, Clone, Default)]
1217
pub struct Devnet {
1318
artifacts_dir: PathBuf,
@@ -211,7 +216,9 @@ impl Devnet {
211216
.with_context(|| "Error while starting the devnet")?;
212217
match status.code() {
213218
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+
)))),
215222
None => Err(anyhow!("Run devnet terminated by signal")),
216223
}
217224
}
@@ -258,7 +265,9 @@ impl Devnet {
258265
.with_context(|| "Error while delegating stakes to the pools")?;
259266
match status.code() {
260267
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+
)))),
262271
None => Err(anyhow!("Delegating stakes terminated by signal")),
263272
}
264273
}
@@ -282,9 +291,9 @@ impl Devnet {
282291
.with_context(|| "Error while writing era marker on chain")?;
283292
match status.code() {
284293
Some(0) => Ok(()),
285-
Some(code) => Err(anyhow!(
294+
Some(code) => Err(anyhow!(UnrecoverableDevnetError(format!(
286295
"Write era marker on chain exited with status code: {code}"
287-
)),
296+
)))),
288297
None => Err(anyhow!("Write era marker on chain terminated by signal")),
289298
}
290299
}
@@ -308,9 +317,9 @@ impl Devnet {
308317
.with_context(|| "Error while to transferring funds on chain")?;
309318
match status.code() {
310319
Some(0) => Ok(()),
311-
Some(code) => Err(anyhow!(
320+
Some(code) => Err(anyhow!(UnrecoverableDevnetError(format!(
312321
"Transfer funds on chain exited with status code: {code}"
313-
)),
322+
)))),
314323
None => Err(anyhow!("Transfer funds on chain terminated by signal")),
315324
}
316325
}

0 commit comments

Comments
 (0)