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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:21:01+00:00 2026-06-14T20:21:01+00:00

I have just been thinking about this, as it is possible but I want

  • 0

I have just been thinking about this, as it is possible but I want to know if it is considered “bad practice”. I believe it is, but I want to ask for views on it to check my opinion.

Is it bad to do something like this:

try{
    something();
    somethingelse();
        try{
            foo();
            bar();
        }catch(Exception e){
            e.printStackTrace();
        }
    somethingelseagain();
}catch(Exception e){
     e.printStackTrace();
}

I think there should never be a need to do this, since anything that throws an exception would trigger the first catch anyway.

Views are greatly appreciated.

  • 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-06-14T20:21:02+00:00Added an answer on June 14, 2026 at 8:21 pm

    In your example, as written, the inner catch is a bit redundant.

    However, nested catches would have more use in circumstances such as:

    • catching different exceptions

    • doing something different in the handler block for the two catches

    • inner catch might catch the exception, do something, then re-throw the same exception which the out catch block could catch

    Also, don’t forget the potential use of the finally block, which can execute cleanup code even if an exception was caught.

    You should generally try to catch the most explicitly typed (i.e. specific) exception(s) as possible.

    The subject of exceptions is an interesting one, and not without controversy.

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

Sidebar

Related Questions

This question is just something that I have been thinking about lately. Can a
I've been thinking about some possible features C++ could have, does anyone know why
Well I have been thinking about this for a while, ever since I was
I have been thinking about a complicated view/query I need to create but I
This is just something I've been thinking about and was wondering if it exists,
I have been thinking about this for a while and cannot come up with
This is probably more a design or style question: I have just been considering
I'm currently using the hilo id generator for my classes but have just been
So this just came to my mind when I was thinking about data serialization
Ok, have a bunch of questions that I have been thinking about the past

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.