Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Possible duplicate of How should I handle exception that *should* never be thrown? Commented Jul 14, 2016 at 22:32
  • What makes code critical in your mind? And why would you want to handle exceptions differently compared to non-critical code? Commented Jul 14, 2016 at 22:51
  • 1
    You will have to figure out what critical operation needs to continue to stay up and running despite exception. This is a higher-level design issue, and thus is unlikely to be handle-able within the method you're showing. For example, in the case of a web server, an exception during processing of a request should not kill the whole web server; that kind of resilience needs to be designed with your overall or larger software situation in mind. Commented Jul 14, 2016 at 23:01
  • 2
    In the .NET world, this sort of analysis isn't going to work for you, unless you're willing to wade through every possible code path in the .NET Framework Reference Source to find every possible exception that might be thrown. That's why every sensible program has one try/catch block at the very top that catches Exception (the ancestor of all exception classes), assuming you don't want your program to crash when it throws one. Commented Jul 14, 2016 at 23:02
  • Irrelevant for the conceptual question, but I think your example is broken. Commented Jul 15, 2016 at 8:02