Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catch-all exception handler in Grails

Tags:

grails

How can I install an exception handler in Grails which catches all exceptions which propagate to the user?

like image 241
Robert Munteanu Avatar asked Sep 17 '09 23:09

Robert Munteanu


1 Answers

You can override the exceptionHandler bean using resources.groovy with your own class that extends GrailsExceptionResolver

e.g.

beans = {
    exceptionHandler(com.yourapp.YourExceptionHandler){
        // this is required so that calls to super work
        exceptionMappings = ['java.lang.Exception': '/error'] 
    }
}
like image 133
leebutts Avatar answered Sep 30 '22 05:09

leebutts