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

The Archive Base Latest Questions

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

At the moment I am developing a website while using the Playframework2. I am

  • 0

At the moment I am developing a website while using the Playframework2. I am just a beginner in programming. I read some books about exceptions but now in the real world , exception handling is really strange.

To be honest I don’t really care what exceptions are thrown I handle all exceptions the same way.
return badrequest(); . I only use exceptions for logging.

try{
...
}
catch(Exeption e){
//log
return badrequest();
}

But this is so much boilerplate and it’s really annoying to write, because every method throws the same exceptions.

Any tips , hints or resources that you could give me?

edit:

An example would be my “global” config file. Because I need to connect to the db every time I thought i could write a singleton for this problem.

private Datastore connect() throws UnknownHostException, MongoException,
            DbAuthException {

        Mongo m = new Mongo(dbUrl, dbPort);
        Datastore ds = new Morphia().createDatastore(m, dbName);
        boolean con = ds.getDB().authenticate(username, password.toCharArray());
        if (!con)
            throw new DbAuthException();
        return ds;
    }

This also results in a try and catch every time I want to connect to the db. My problem is I don’t think I can handle them diffidently.

A code example :

public static Result addComment(String title) {
        try {

            Datastore ds = DatabaseConnect.getInstance().getDatastore();
            Form<Comment> filledForm = commentForm.bindFromRequest();
            Comment userComment = filledForm.get();
            userComment.setUsername(Util.getUsernameFromSession(ctx()));
            User.increasePointsBy(ctx(), 1);
            UserGuides.addComment(title, userComment);
        } catch (Exception e) {
            return badRequest();
        }
        return redirect(routes.Guides.blank());
    }

In this case I was to lazy to write the same try and catch over and over again, and this is duplicated code.

Maybe there is a book that explains how to design a big application with exception handling?

  • 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-10T00:37:27+00:00Added an answer on June 10, 2026 at 12:37 am

    When you invoke a method, you do not necessarily have to catch the exceptions right there. You can let your callers handle them (declaring a throws clause if it is a checked exception). In fact, the ability to pass them on to the callers without any additional work is the distinguishing feature of exceptions.

    My team has adopted the following coding standard: We throw checked exceptions for those rare cases when we want to recover from a failure, and unchecked exceptions for anything else. There is only a single catch block for the unchecked exceptions in a method so high in the call stack that all requests pass through it (for instance in a ServletFilter). This catch block logs the exception, and forwards the user to the “Sorry, this shouldn’t have happened” page.

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

Sidebar

Related Questions

I'm developing a website using Rails 3, and at this moment I wanted to
I am developing a website using Django as the backend, and I want to
Greetings, we are a the moment developing a website for intranet use. The user
At the moment I'm developing a web based application using Silverlight 3.0. For the
At the moment I'm developing using a simple editor, putty, and a VirtualBox instance
I'm not very skilled in web developing by the moment but i've managed to
Im at the moment developing a very heavy website which i need to optimize
I'm creating a login script for a website I'm developing. At the moment I
I have been developing a website for a University coursework, and at the moment,
I'm developing a website using PHP+Ajax. I have to fire a ajax request that

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.