javaglobalinvokeplayframework-2.2onerror

playframework invoke onError method inside Globaj.java object


I am working with global object in Playframework. I've already created methods:

I've created method onError:

    public Promise<SimpleResult> onError(RequestHeader request, Throwable t) {
        Logger.error("Request: " + request + "generated error: " + t.toString());
        return Promise.<SimpleResult>pure(internalServerError(
            views.html.errorPage.render("500", "Errors occured")
        ));
    }

But I would like to test it. Please tell me how can I invoke this method to test it?


Solution

  • Create entry in routes file:

    GET /testOnError controllers.ErrorController.testOnError

    Error controller:

        public static Result testOnError() {
             throw new IllegalArgumentException();
        }
    

    Navigate to:

    http://HOST:PORT/testOnError