pub fn capture_error<E: Error>(
err: &E,
context: HashMap<String, Value>,
user: Option<HashMap<String, Value>>,
)Expand description
Reports an error you’ve already handled. Call it right at the point you’d otherwise just log it:
if let Err(err) = charge_card() {
forge_ops_tracker::capture_error(&err, HashMap::new(), None);
}The backtrace is captured right here, at the call site: unlike Python/Java/PHP, a plain Rust
std::error::Error carries no stack of its own, so capture_error has to be the one call that
knows where the trace starts. exception_class is inferred via std::any::type_name, which
needs E to be a concrete, statically-known type: for a Box<dyn Error> or other trait
object, where that isn’t possible, use capture_error_with_class instead and supply the
class yourself.
user defaults to whatever set_user last established on this thread, if anything (None
here means “use that”, not “no user”); pass Some(..) to override it for this one report.