Grails中的Catch-all异常处理程序

Rob*_*anu 5 grails

如何在Grails中安装异常处理程序,捕获传播给用户的所有异常?

lee*_*tts 17

您可以使用resources.groovy使用您自己的扩展GrailsExceptionResolver的类来覆盖exceptionHandler bean

例如

beans = {
    exceptionHandler(com.yourapp.YourExceptionHandler){
        // this is required so that calls to super work
        exceptionMappings = ['java.lang.Exception': '/error'] 
    }
}
Run Code Online (Sandbox Code Playgroud)