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 7179489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:09:01+00:00 2026-05-28T17:09:01+00:00

Possible Duplicate: When to use try/catch blocks? Main method code entirely inside try/catch: Is

  • 0

Possible Duplicate:
When to use try/catch blocks?
Main method code entirely inside try/catch: Is it bad practice?
When to use Try Catch blocks

Exceptions can occur about anywhere, so this made me think: should I always wrap my code in try..catch blocks?

This is for C#.

(I might be missing something fundamental here, as I’m still a newbie)

EDIT: It appears that this was indeed not a very smart question. The only thing we have learnt at school is to use try…catch to prevent crashes. What we did with the exception was showing a MessageBox to tell the user that ‘something went wrong when writing this file’.

  • 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. Editorial Team
    Editorial Team
    2026-05-28T17:09:02+00:00Added an answer on May 28, 2026 at 5:09 pm

    Exceptions can occur about anywhere, so this made me think: should I always wrap my code in try..catch blocks?

    Good question. Here’s a related question:

    Axe-wielding maniacs can be just about anywhere, so: should I wear axe-resistant body armor 24 hours a day?

    I am fortunate to live in a neighborhood where the number of axe-wielding maniacs is sufficiently low that I don’t wear armor when I leave the house. But suppose I did not. Is the right solution to wear the armor all the time or to jail the maniacs?

    If your programs throw so many exceptions that you need to be handling those exceptions everywhere, then you have a big problem. The solution to that problem is not to armor up and put exception handling everywhere. The solution to that problem is to eliminate the code that is throwing the exceptions, and if you cannot eliminate it, then isolate it to a tiny region of code that does use exception handling.

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

Sidebar

Related Questions

Possible Duplicate: Do try/catch blocks hurt performance when exceptions are not thrown? Hey everyone,
Possible Duplicate: How can I use a carriage return in a HTML tooltip? I'd
Possible Duplicate: What is the advantage of using try {} catch {} versus if
Possible Duplicate: Catching specific vs. generic exceptions in c# Here's an example method private
Possible Duplicate: Array versus List<T>: When to use which? Is there any best practice
Possible Duplicate: Can you write object oriented code in C? I'm wondering if it's
Possible Duplicate: Deflate command line tool Yes, I know I can use PHP itself
Possible Duplicate: In C++ what are the benefits of using exceptions and try /
Possible Duplicate: How can you use PowerShell's . (dot) notation to walk through elements
Possible Duplicate: Objective C alloc/release error When I try the code below it crashes

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.