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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:37:41+00:00 2026-05-21T05:37:41+00:00

i would like to handle my exceptions in a way to warning the user

  • 0

i would like to handle my exceptions in a way to warning the user about the errors that occured .

What i know is something like:

servlet.java
private void registerUser(...){
    ...
    try{
        DAOUser daoUser = new DAOUser();
        daoUser.insert(user);
    catch(HibernateException he){
        ...
    }

DAOUser.java
public void insert(User user) throws HibernateException {
  ...
}

This is the best approach ? If not, what would you suggest ?

Best regards,
Valter Henrique.

  • 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-21T05:37:42+00:00Added an answer on May 21, 2026 at 5:37 am

    An exception can be handled in different ways. In this case, it seems that the exception is resulting in a user notification or an error message.

    Now, the example you have shown should not throw any exception of that sort, where you need to notify user. First, validate user input; second, don’t make the flow of your program using exceptions.

    Well, there are exceptions where we need to notify the user with some message. That can be done in controller, typically, using messages stored in property files.

    You must know where to catch exception, where to throw it, and where to log. Here first thing I would like to suggest is not to do both, throw and log. If you think logging is appropriate, don’t throw it. If you think throwing is appropriate, then don’t log it. When you follow this way, you will automatically know which one you need to log and which one to throw. That doesn’t mean some exceptions would go away without logging. The method, which doesn’t throw that further, holds the responsibility to log that exception.

    Another thing is to know where to use checked exception and where to use runtime. The methods which throw runtime exceptions are somewhat easier to use, per se. But that doesn’t essentially mean that you should always use runtime exceptions.

    I hope you are getting my points.

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

Sidebar

Related Questions

In Java, we handle exceptions using try catch blocks. I know that I can
Ok I really would like to know how expert MVVM developers handle an openfile
Would like to make anapplication in Java that will not automatically parse parameters used
What's the best way to handle exceptions that happen from within a controller's constructor?
I learned that Objective-C has an equivalent way of handling exceptions like C# does
I would like to get a second opinion on how to handle Exceptions within
I would like to know some of the strategy/practice you deal with to handle
I am working on a RoR website and would like to handle server errors
I would like to know, is there any way to set up TestNG to
I have a JPanel that handles a bunch of settings that I would like

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.