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

时间:2009-09-17 23:07:17

标签: grails

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

1 个答案:

答案 0 :(得分:16)

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

e.g。

beans = {
    exceptionHandler(com.yourapp.YourExceptionHandler){
        // this is required so that calls to super work
        exceptionMappings = ['java.lang.Exception': '/error'] 
    }
}
相关问题