Fix error display in tx simulate.
This commit is contained in:
parent
01c392836e
commit
014c7a3d73
|
@ -128,15 +128,16 @@ pub fn exec(
|
||||||
cpu: accum.cpu + curr.ex_units.steps as i64,
|
cpu: accum.cpu + curr.ex_units.steps as i64,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eprintln!("\n");
|
||||||
println!(
|
println!(
|
||||||
"\n{}",
|
"{}",
|
||||||
serde_json::to_string(&total_budget_used)
|
serde_json::to_string(&total_budget_used)
|
||||||
.map_err(|_| fmt::Error)
|
.map_err(|_| fmt::Error)
|
||||||
.into_diagnostic()?
|
.into_diagnostic()?
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("{} {}", " Error".bold().red(), err.red());
|
eprintln!("{}", display_tx_error(&err));
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,3 +145,32 @@ pub fn exec(
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn display_tx_error(err: &tx::error::Error) -> String {
|
||||||
|
let mut msg = format!("{} {}", " Error".bold().red(), err.red());
|
||||||
|
match err {
|
||||||
|
tx::error::Error::RedeemerError { err, .. } => {
|
||||||
|
msg.push_str(&format!(
|
||||||
|
"\n{}",
|
||||||
|
display_tx_error(err)
|
||||||
|
.lines()
|
||||||
|
.skip(1)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n"),
|
||||||
|
));
|
||||||
|
msg
|
||||||
|
}
|
||||||
|
tx::error::Error::Machine(_, _, traces) => {
|
||||||
|
msg.push_str(
|
||||||
|
traces
|
||||||
|
.iter()
|
||||||
|
.map(|s| format!("\n{} {}", " Trace".bold().yellow(), s.yellow()))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("")
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
msg
|
||||||
|
}
|
||||||
|
_ => msg,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub enum Error {
|
||||||
FlatDecode(#[from] flat_rs::de::Error),
|
FlatDecode(#[from] flat_rs::de::Error),
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
FragmentDecode(#[from] pallas_primitives::Error),
|
FragmentDecode(#[from] pallas_primitives::Error),
|
||||||
#[error("{}\n\n{:#?}\n\n{}", .0, .1, .2.join("\n"))]
|
#[error("{}", .0)]
|
||||||
Machine(machine::Error, ExBudget, Vec<String>),
|
Machine(machine::Error, ExBudget, Vec<String>),
|
||||||
#[error("Native script can't be executed in phase-two")]
|
#[error("Native script can't be executed in phase-two")]
|
||||||
NativeScriptPhaseTwo,
|
NativeScriptPhaseTwo,
|
||||||
|
|
Loading…
Reference in New Issue