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

The Archive Base Latest Questions

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

I recently came across code written by a fellow programmer in which he had

  • 0

I recently came across code written by a fellow programmer in which he had a try-catch statement inside a catch!

Please forgive my inability to paste the actual code, but what he did was something similar to this:

try
{
 //ABC Operation
}
catch (ArgumentException ae)
{
   try
   {
      //XYZ Operation
   }
   catch (IndexOutOfRangeException ioe)
   {
      //Something
   }
}

I personally feel that it is some of the poorest code I have ever seen!
On a scale of 1 to 10, how soon do you think I should go and give him a piece of my mind, or am I over-reacting?

EDIT:
What he is actually doing in the catch, he is performing some operations which can/should be done when the initial try fails. My problem is with having a clean code and maintainability. Delegating the exception from the first catch to a different function or the calling function would be OK, but adding more code which may or may not throw an exception into the first catch, is what I felt was not good. I try to avoid multiple stacked “if-loop” statements, I found this equally bad.

  • 1 1 Answer
  • 3 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-16T09:16:12+00:00Added an answer on May 16, 2026 at 9:16 am

    Why is that bad? It’s no different conceptually than:

    void TrySomething() {
       try {
    
    
       } catch (ArgumentException) {
            HandleTrySomethingFailure();
       }
    }
    
    void HandleTrySomethingFailure() {
        try {
    
        } catch (IndexOutOfRangeException) {
    
        }
    }
    

    Before you go over there and give him a piece of your brain (try the parietal lobe, it’s particularly offensive) , what exactly are you going to say to him? How will you answer the proverbial “why?”

    What’s even more ironic is that when the jitter inlines this code, it will look exactly like your example.

    -Oisin

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

Sidebar

Related Questions

I recently came across a piece of Java code with WeakReferences - I had
I recently came across some code like this: parent && parent.removeChild(this); Which takes the
I was working on some code recently and came across a method that had
i recently came across a part of code which looks like as follows: static
I recently came across the following piece of code. It doesn't look valid because
I recently came across some Java code that simply put some strings into a
I recently came across the following line of code: var type = (typeof x).toLowerCase();
I recently came across the pandas library for python, which according to this benchmark
I recently came across the term Polymorphic Code , and was wondering if anyone
I recently came across some code that looks something like this: <head> <?php /*

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.