brandones
brandones

Reputation: 1937

How to find the catch statement for an error in the Chrome debugger?

I'm working with React. In a component constructor, an error is being thrown, but it's clearly being caught and swallowed because I only find out about it by clicking "Pause on Caught Exceptions." Is there any way to find out where the catch statement is? I've stepped through the code many times and have yet to find the catch statement.

Upvotes: 3

Views: 1579

Answers (2)

David Mulder
David Mulder

Reputation: 26995

For future reference, an alternative place an error might get 'caught' is Promise.allSettled. The way I finally found this through a debugger was similar to Matt Zeunert's suggestion, but instead I did it in Firefox, which - unlike Google Chrome! - steps up through the stack trace in that case until it gets to the Promise.allSettled.

Upvotes: 0

Matt Zeunert
Matt Zeunert

Reputation: 16561

If you've paused on the caught exception, clicking "Step over" in the stepping controls should show you the catch handler.

enter image description here

Upvotes: 1

Related Questions