Skip to main content

error_chain

Function error_chain 

Source
pub fn error_chain(err: &(dyn Error + 'static)) -> String
Expand description

Render an error together with its full source() chain, e.g. error sending request for url (...): dns error: failed to lookup address information: ....

Several error types this crate surfaces to Rhai — most notably reqwest::Error for a connection-level failure (DNS, TLS, timeout, connection refused) — implement std::fmt::Display on the outer error only, leaving the actual cause reachable solely through Error::source() (i.e. visible in {:?} but not {}). Without walking the chain, a script (and whatever surfaces its error, e.g. a JukeBox Updated condition) only ever sees an opaque “error sending request for url (…)” with no indication of why the request failed. A source already restating an ancestor’s message verbatim (e.g. Error::ReqwestError’s #[error("Reqwest error: {0}")] Display, which embeds its wrapped reqwest::Error’s own Display) is skipped rather than appended again.