Why can’t I catch an exception from async code?

You have the “Just my code” Option turned on. With this on, it is considering the exception unhandled with respect to “just your code”–because other code is catching the exception and stuffing it inside of a Task, later to be rethrown at the await call and caught by your catch statement.

Without being attached in the debugger, your catch statement will be triggered, and it will run as you expect. Or you can just continue from within the debugger and it will run as expected.

The better thing to do is to just turn off “Just my code”. IMO, it causes more confusion than it is worth.

Leave a Comment