sim-cli 0.5.1

CLI tool for running and comparing Solana simulator backtests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::{error::Error, fmt::Write};

/// Format an error with its full `source()` chain joined by `: `.
///
/// `Display` on most error types (notably `reqwest::Error` and
/// `tokio_tungstenite::Error`) only emits the top-level reason and discards
/// the underlying cause. That makes log output like "error sending request
/// for url (...)" useless for diagnosing whether it was DNS, TLS, a reset,
/// or a timeout. Walking the source chain restores the actionable detail.
pub(crate) fn err_chain(e: &(dyn Error + 'static)) -> String {
    let mut out = e.to_string();
    let mut src = e.source();
    while let Some(s) = src {
        let _ = write!(&mut out, ": {s}");
        src = s.source();
    }
    out
}