Dart-Code icon indicating copy to clipboard operation
Dart-Code copied to clipboard

Add Option to Ignore Exceptions Similar to Visual Studio

Open ristiisa opened this issue 1 year ago • 6 comments

Is your feature request related to a problem? Please describe. During the debugging process, where the debugger halts execution for exceptions that are already expected and handled within the application. In complex systems, especially those that utilize third-party libraries or APIs, it's common to encounter a variety of exceptions that are non-critical and handled gracefully by the application's logic.

The problem arises when these known, non-critical exceptions significantly disrupt the debugging workflow, requiring developers to manually continue the execution each time such an exception is encountered. This not only slows down the debugging process but also detracts from the focus on genuinely critical issues that require attention. The ability to ignore specific exceptions during debugging sessions in Visual Studio significantly mitigates this issue, providing a smoother and more efficient debugging experience.

Describe the solution you'd like I propose implementing a feature similar to Visual Studio's exception ignoring capability, which allows developers to predefine exceptions that the debugger should overlook. To those who are not familiar with the feature https://learn.microsoft.com/en-us/visualstudio/debugger/managing-exceptions-with-the-debugger?view=vs-2022

There was an issue https://github.com/Dart-Code/Dart-Code/issues/2670 about this issue before but it died off.

ristiisa avatar Mar 13 '24 15:03 ristiisa

There was an issue https://github.com/Dart-Code/Dart-Code/issues/2670 about this issue before but it died off.

I think the request there was a little different - it was to be able to break on an exception and then say "continue and ignore this specific exception bubbling up".

If I understand correctly, this request is more about saying "Ignore PathNotFoundException" but break on everything else?

Are you able to give a more concrete example, including what your current debug sessions are ("All exceptions" vs "Uncaught exceptions, and whether you have "debug my code" or "debug my code + packages" or "+ sdk" etc.).

Can you also clarify whether you're looking to exclude some exceptions or include them? (eg. "break on everything except PathNotFoundException" or "only break on PathNotFoundException")

The debugger adapter protocol has some support for "ExceptionFilterOptions" but I'm not yet sure how much of it VS Code supports, so it will require some testing and it would be good to have some real-world examples of what would be useful.

Thanks!

DanTup avatar Mar 13 '24 16:03 DanTup

If I understand correctly, this request is more about saying "Ignore PathNotFoundException" but break on everything else?

Yes!

Are you able to give a more concrete example, including what your current debug sessions are ("All exceptions" vs "Uncaught exceptions, and whether you have "debug my code" or "debug my code + packages" or "+ sdk" etc.).

The idea is that when you are have a exception handling in place so all the exceptions that happen are "handled" and you are trying to debug a specific situation that triggers this weird situation. But since the code base relies heavily on Exceptions, just focusing on this one specific exception is currently not easy without code changes.

Can you also clarify whether you're looking to exclude some exceptions or include them? (eg. "break on everything except PathNotFoundException" or "only break on PathNotFoundException")

I think at first it would be best to just focus on excluding.

The debugger adapter protocol has some support for "ExceptionFilterOptions" but I'm not yet sure how much of it VS Code supports, so it will require some testing and it would be good to have some real-world examples of what would be useful.

Would a code sample be useful?

ristiisa avatar Mar 13 '24 17:03 ristiisa

Thanks, that helps. I'll have to do some testing of how VS Code presents ExceptionFilterOptions to see whether that's a good fit for something like this.

DanTup avatar Mar 14 '24 15:03 DanTup

@DanTup here is the sample dart program https://github.com/ristiisa/exampletogeneratesomeexceptions

So sometimes we get "handled" exceptions (NonCriticalException) and sometimes we get exceptions that are handled but not desired. In the example int.parse will fail sometimes, but not always.

We would like to know why it fails, but we have this pesky NonCriticalException that prevents us from using "break on all exceptions" and since all exceptions are handled (to prevent application crash) "break on uncaught exceptions" will not trigger.

The goal is to tell the debugger that "NonCriticalException" should be ignored when "break on all exceptions" is enabled.

ristiisa avatar Apr 02 '24 08:04 ristiisa

Just stumbled upon this. I think the other option being able to say to ignore a certain exception after the debugger stopped the first time on it would also be very helpful in many cases. So both would be a great addition

escamoteur avatar Apr 10 '24 10:04 escamoteur