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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:49:03+00:00 2026-06-14T21:49:03+00:00

I read in a C# introductory book that you shouldn’t catch an exception if

  • 0

I read in a C# introductory book that you shouldn’t catch an exception if you don’t know what to do with it. Thinking of that bit of advice while programming in Java, I sometimes find I do not know what to do with an exception, but I am forced to catch it or “percolate it up” to avoid a compile error. I’d rather not clutter methods with throws clauses all the way up the call tree so I have often resorted to “converting” the exception to a RuntimeException as in the following. Adding throws clauses to many methods for an exception that isn’t really “handled” (properly dealt with) seems verbose and distracting. Is the following bad style and if so what is a better way to deal with this?

try {
  thread.join();
}
catch (InterruptedException e) {
      Console.printwriter.format("%s\n", e.printStackTrace());
  throw new RuntimeException();
}

Edit: Aside from the clutter, there’s another problem with the percolating exceptions: after code revisions you probably end up with some unnecessary throws clauses. The only way I know to clean them out is by trial and error: remove them and see if the compiler complains. Obviously, this is annoying if you like to keep the code clean.

  • 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-14T21:49:05+00:00Added an answer on June 14, 2026 at 9:49 pm

    The division in Java between checked and unchecked exceptions is somewhat controversial.

    If you control the interface, adding a throws clause to the signature is usually the best way.

    If you are in a situation where you cannot deal with an exception, but are not allowed to let it bubble up because of the checked exception signature, then wrapping the exception into an exception that you can rethrow (often a RuntimeException) is common practice.

    In many cases, you’d want to use another checked exception, though, such as IOException or SQLException. But that is not always an option.

    But in your example, include the original exception as the “cause”:

     throw new RuntimeException(e);
    

    This may also remove the need for the logging (because this can also be deferred to someone who can handle the exception, and all information is still there).

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

Sidebar

Related Questions

A simple best practices question that I haven't seen addressed in the introductory programming
Read (skimmed enough to get coding) through Erlang Programming and Programming Erlang . One
I am currently in an introductory c++ class and am working assignment that sorts
I'm having a bit of trouble with a problem from an online course (Introductory
Read that the following code is an example of unsafe construction as it allows
A read some posts here and google and don´t find a substancial answer. Supose
I read somewhere that Apple encourages the use of NSURL over NSString in terms
I read a book about paging (memory-management schemes). As I understand, each virtual memory
I read on the facebook documentation ( here ) that you can force a
Can somebody tell me where I can read about NSerivceBus for introductory information ?(What

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.