MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / get_error_reason

Function get_error_reason

crates/chat-cli/src/telemetry/mod.rs:754–770  ·  view source on GitHub ↗

Returns a generic error reason + reason description pair.

(error: &E)

Source from the content-addressed store, hash-verified

752
753/// Returns a generic error reason + reason description pair.
754pub fn get_error_reason<E>(error: &E) -> (String, String)
755where
756 E: ReasonCode + 'static,
757{
758 let mut err_chain = eyre::Chain::new(error);
759 let reason_desc = if err_chain.len() > 1 {
760 format!(
761 "'{}' caused by: {}",
762 error,
763 err_chain.next_back().map_or("UNKNOWN".to_string(), |e| e.to_string())
764 )
765 } else {
766 error.to_string()
767 };
768
769 (error.reason_code(), reason_desc)
770}
771
772#[cfg(test)]
773mod test {

Callers 5

nextMethod · 0.85
send_messageMethod · 0.85
compact_history_implMethod · 0.85
handle_responseMethod · 0.85

Calls 3

to_stringMethod · 0.80
lenMethod · 0.45
reason_codeMethod · 0.45

Tested by

no test coverage detected