Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 152769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:40:57+00:00 2026-05-11T09:40:57+00:00

I’ve read a lot of times that one should never blindly catch exceptions. Some

  • 0

I’ve read a lot of times that one should never blindly catch exceptions. Some people say it’s ok to wrap your Main() into a catch block to display errors instead of just exiting (see this SO post for example), but there seems to be a consensus that you should never let your program running if something unexpected occurred, since it’s in an unknown state, and may act in unexpected ways.

While I agree on the fact that hiding bugs rather than fixing ’em is definitely a wrong idea, consider the following case :

You’ve got a huge server. Million of lines of code.

When it starts, it loads all the Customer into its local cache.

To, me, it makes a lot of sense to write this :

           foreach (string CustomerID in Customers)                 try                 {                     LoadCustomer(CustomerID);                 }                 catch (Exception ex) // blind catch of all exceptions                 {                     // log the exception, and investigate later.                  } 

Without the blind catch, failing to load a single Customer would just crash all the server.

I definitely prefer having my server up with a little unknown side effect on one customer rather than my whole server down.

Of course, if I ever run my catch code, the first thing I’ll do is fix the bug in my code.

Is there something I’m overlooking here? Are there known best practices (other than the ‘never catch unexpected exception’ strategy’?)

Is it better to catch the exception in the LoadCustomer() method, to rethrow a ‘CustomerLoadException’ from there, and to catch CustomerLoadException instead of all Exception in the calling code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:40:58+00:00Added an answer on May 11, 2026 at 9:40 am

    This is a question of Robustness, that is continuing to operate even in the event of unexplainable errors, vs Correctness, prefering to fail completely rather than produce unreliable results.

    Clearly if you are working on, for example, life-support systems, you don’t want your system to simply shut down due to an unknown error condition. Cotninuing to operate, even if your state isn’t well defined, is probably better than terminating.

    On the other hand, if your program is a shopping cart, it’s probably better to simply fail completely rather than potentially send the wrong item, or charge the wrong amount of money to the wrong individuals.

    Everything in between is a gray area and it’s a judgment call. In the main, it would seem that life-support systems programming is more rare than shopping-cart programming, so the broad advice is for people to do what’s most common, which is fail in the event of an unexpected error. It’s understood that if you are working on a case where that’s not appropriate (such as your server example), you will know better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.