Reputation: 14685
How/where should I set up exception handling, so that I can throw a somewhat generic "oops - simply can't deal with this" style of exception and handle it moderately gracefully?
The answer to this question hints that it should be elegant (AppException), and of course it should but I can't quite figure where the catching should be and how it should cause a subsequent error page render...
(google reveals answers to this in the scala world, but I haven't been able to get my head around what the equivalent is in java).
Upvotes: 2
Views: 4213
Reputation: 1
develop Global.java under default package extending from GlobalSettings and implement onError (-)method , it will handle the exception
Upvotes: 0
Reputation: 3294
See "Providing an application error page" here: http://www.playframework.com/documentation/2.2.1/JavaGlobal
It's a global exception handler so you don't need to catch anything.
Note: if you copy&paste provided code, you need to create a new view named "errorPage" that takes one argument of type Throwable. Something like this:
@(t: Throwable)
<h1>My Error page</h1>
@t.getMessage
Upvotes: 8