pub fn with_code<C: ErrorCode>(
err: Error,
code: impl Fn(&Error) -> Option<C>,
) -> ErrorAvailable on crate feature
terminal only.Expand description
err as the report reads it, the code code finds in its chain
carried by an innermost CodedError.
A binary may read a code off a typed error deep in the chain (a
protocol refusal, a bare 403 or 429), which code_of does not see.
err is returned unchanged when the chain already carries a code of
C, usage-invalid or a PartialOutcome, or when code finds
none; else it is rebuilt with the same messages, outermost first.