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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:18:28+00:00 2026-05-16T08:18:28+00:00

If you have: catch (FooException ex) { throw new BarException (ex); } catch (BarException

  • 0

If you have:

catch (FooException ex) {
    throw new BarException (ex);
}
catch (BarException ex) {
    System.out.println("hi");
}

…and the first catch clause is triggered (i.e. FooExcepetion has occurred),
does the new BarException get immediately caught by the subsequent “catch” clause?

Or is the new BarException thrown one level up the continuation stack?

I realize this is a basic question. : )

  • 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-16T08:18:28+00:00Added an answer on May 16, 2026 at 8:18 am

    It does not get caught by the 2nd catch clause, no.

    Each catch clause in the list is tried, to see if it matches. The first one that matches is the only one that runs, then the code moves on to the finally clause.

    Another result of this is that if you have:

    try {
        throw SubTypeOfException(...);
    } catch(Exception e) {
        ... block 1 ...
    } catch(SubTypeOfException e) {
        ... block 2 ...
    }
    

    then block 1 is the only one that will run, even though block 2 would have matched. Only the first matching catch clause is evaluated.

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

Sidebar

Related Questions

In my application I have to catch the new incoming email massage notification and
I have a try catch and finally block like this. Client client = new
Possible Duplicate: When does Java's Thread.sleep throw InterruptedException? I saw we have to catch
I want to have a 'catch all' route which runs when none of the
I know try catch have been discussed a lot but I haven’t found a
In my Java code, I occasionally run into situations where I have to catch
I have a Try Catch in my code. I would like to know if
What have people used to catch, log, and report multiple data validation errors at
I have never used Try-catch in my code before, but now I need to
I have created a device orientation listener to catch when the device is rotated,

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.