1

When working with Exceptions I always like to not-break on specific try/catch statements.

Examples:

  • I never want to break on this TimeoutException in a very specific case where I expect it to happen often (often in a deeper layer).
  • I do want to break on all other TimeoutExceptions.
  • For a very high level try/catch I actually never want to swallow the Exception before it breaks. Say a try/catch on the highest lever of some worker process.

In VS there is an ignore based on ExceptionType and an 'except from this dll' property.

For me this is often not really sufficient, but more a workaround. You have to be lucky that they actually wrote a specific Exception that you can catch and ignore. Adding a seperate assembly for just this functionality seems overkill.

Question

Is it possible to say 'never break on this and this try/catch' - but do break on all others?

Dirk Boer
  • 8,522
  • 13
  • 63
  • 111
  • 1
    Possible duplicate of: https://stackoverflow.com/questions/3688574/make-visual-studio-ignore-exceptions – Robert S. Jul 25 '17 at 09:36
  • @Robert S. I don't think this is a duplicate. This question asks how to ignore specific ```catch```-blocks, not complete ```Exception```-types – Iqon Jul 25 '17 at 09:40
  • Ok my bad. But then it is a possible duplicate of: https://stackoverflow.com/questions/1420390/dont-stop-debugger-at-that-exception-when-its-thrown-and-caught/3455100#3455100 – Robert S. Jul 25 '17 at 09:53
  • @Dirk Boer, What about this issue now? Do you will use certain attribute in your side like DebuggerNonUserCode or others? https://blogs.msdn.microsoft.com/devops/2016/02/12/using-the-debuggernonusercode-attribute-in-visual-studio-2015/# – Jack Zhai Jul 26 '17 at 08:04
  • Hi Jack, still need to try it out but it seems to be able to take care what I'm looking for! – Dirk Boer Jul 26 '17 at 11:11
  • @Dirk Boer, You could test it in your side, if you get any latest information, please feel free to share it here. – Jack Zhai Jul 27 '17 at 06:00
  • @Dirk Boer, Whether this issue has been resolved in your side? Do you will use the debugging attribute in your side? – Jack Zhai Aug 01 '17 at 06:02
  • Hi Jack Zhai-MSFT, still didn't test it - I'll test it next time this problem arises again! At the moment busy delivering some new milestones. – Dirk Boer Aug 01 '17 at 11:48

1 Answers1

0

See Don't stop debugger at THAT exception when it's thrown and caught and the answers there. Especially the attribute System.Diagnostics.DebuggerHidden might help in this case.

Robert S.
  • 1,942
  • 16
  • 22
  • You might consider using multiple catch blocks like this try { } catch (TimeoutException ex) { //Break here } catch (Exception ex) { } Then you are able to handle each exception as you want – Taco2 Jul 25 '17 at 09:55