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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:47:37+00:00 2026-06-10T18:47:37+00:00

Where is the proper place to handle thrown exception from lower layers.. inside the

  • 0

Where is the proper place to handle thrown exception from lower layers.. inside the class or at the possible toppest level? OR it depends to the use case?

  • 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-10T18:47:39+00:00Added an answer on June 10, 2026 at 6:47 pm

    You can take a look at this post:

    In particular it is now possible (and considered good practice) to set up a top-level exception handler that will handle any unexpected exception on the main thread in a Windows application. This means that it is no longer necessary to have exception handlers in every routine.

    You may also look at How to implement top level exception handling?

    And one link for exception handling in Java http://onjava.com/pub/a/onjava/2003/11/19/exceptions.html

    So, as a general answer to your question: I would say that yes it depends on the use case (is it just your simple short script or a full-fledged application), but you should try to do the exception handling at the highest possible level, and while doing that do keep in mind the “technicality” of the message you present to your users (trust me, a message “error 31231241 in main thread” doesn’t improve user friendlines of your application).

    edit:
    As Steve McConnell also states in his famous Code Complete 2 book, one should Throw exceptions on the right level of abstraction - for example if you have a getUser() method and you return IOException then that would be very bad. But yes, I think that’s commmon sense. Also, he says that one should write a function in such manner that if some other function sends it “garbage”, it should not cause a crash of the whole program.

    Also, he is in favor of using assertions, and he says: Use error handling code for the conditions you expect to occur; use assertions for conditions that should never occur.

    Finally, the states that while addressing the errors you should keep in mind the two approaches: robustness and correctness. The story he tells in the book for this example is very vivid and stayed in my head long after I’ve read it. Consider having a “Text editing application” and take into account the correctness of the data presented. Imagine few pixels “go wild” (you misscalculate them, or sth like that) – for sure you wouldn’t consider to force close the application if something like that happens and this is called robustness (continue operating). But, imagine now that you’re making an X-ray manipulation application- in this case any “wierd data” should (as McConnell suggest) cause the critical error message and it is said that you’re striving for correctness in your applicaiton.

    P.S. pardon for the CC2 part, but I just love that book and think every developer should read it (at least once).

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

Sidebar

Related Questions

What's the proper way to add a literal text value from a field to
QUESTION: What is the proper way to use .get() in conjunction with .one() (or
Where is the proper 'place' in JSF to put initialisation snippet that follows, in
Where is the proper place to perform validation given the following scenario/code below: In
What is the proper place to explain error handling in a try-catch statement? It
EDIT : proper solution: void add(Student s) { if(root == null) root = new
xml is not encoding proper - any help List<NameValuePair> formparams = new ArrayList<NameValuePair>(); formparams.add(new
What is the proper method to set the focus onload to first field in
I was looking a proper way to implment a ScaleAnimation. My purpose is to
What are the proper ways of adding a common set of method/properties to subclasses

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.