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

  • Home
  • SEARCH
  • 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 6792489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:58:33+00:00 2026-05-26T17:58:33+00:00

I was looking at some code that I am refactoring and notices the try

  • 0

I was looking at some code that I am refactoring and notices the try … catch code wraps quite a lot of code, not of all which would throw “normal” exceptions i.e. The code wouldn’t throw at all or if it did it would be totally fatal exceptions like out of memory exceptions.

What I am wondering now is whether wrapping too much in try statements can cause any issues with performance?

So I see something like this:

try
{
    // Won't throw (I think that is the case anyway!)
    if (e.Error == null)
    {
        return;
    }

    // Only fatal exceptions
    myClass c = new myClass();

    // Now carry out the code that could cause catchable exception
}
catch
{
}
  • 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-26T17:58:34+00:00Added an answer on May 26, 2026 at 5:58 pm

    Performance issues? Nothing that should be noticeable, really. From a bug hunting perspective, however, it can be a nightmare. When you wrap 100 lines of code in a try/catch its harder to figure out which of those 100 lines threw an exception. And despite all logic (or actually because of flawed human logic), code that “should never throw an exception” often throws the most.

    I say, if you have code that should never throw an exception then back it up by not wrapping it in a try/catch block. Otherwise just try/catch your Main method and be done with it.

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

Sidebar

Related Questions

I was looking for some utility class/code that would take a java bean and
I'm looking for an equivalent of: for(_ <- 1 to n) some.code() that would
I'm looking at some existing code that is generating a salt which is used
I'm looking for some sample code that will sort the list items in an
I'm looking to reimplement some Tcl code that uses the socket -server construct [1].
Looking at some code I'm maintaining in System Verilog I see some signals that
I am testing some weird-looking CSS code that I wrote (I'm using a mix
I'm looking for a tool that works on Windows to reformat some C++ code
I'm looking for a library that will disassemble x86 code into some sort of
I am currently refactoring some old code. I am looking for directions on the

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.