Pause on Err in debugger?

We have "pause on panic" or "pause on throw" in debugger. However in Rust, many recoverable errors are handled directly in code by creating Err(...) and then they are propagated. In some cases I need to quickly find out where the first Err(...) was created. Is there any trick?

1 Like

? operator calls TheFunctionsErrorType::from(), so perhaps you could put a breakpoint there.

There are libraries like anyhow that add a stack trace to their error objects. Errors sometimes return more context from their source() method.

but apart from that, errors are just regular types returned from functions normally, so if a function returning an error doesn't collect and return more context, there isn't one.

1 Like

looks like .source() in Error in std::error - Rust is what I want to try.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.