Catch-all exception handler in Grails

Tag: grails Author: aixiaowen Date: 2009-09-01

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

Best Answer

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'] 
    }
}