exception - 为什么 Grails 会删除我的异常?

标签 exception grails groovy error-handling

如果你把它放在一个 Controller Action 中:

def inner = new RuntimeException("inner")
def middle = new Exception("middle", inner)
def outer = new IllegalArgumentException("outer", middle)
throw outer

Grails 的错误调试页面(最重要的是日志)只会显示内部异常类及其消息:

Error 500: Internal Server Error

URI: /...
Class: java.lang.RuntimeException
Message: inner



这是有问题的,因为当您选择用更具描述性的消息包装异常时,大多数情况下,外部消息在调试问题时更为重要。

实际上,在原因链中包含所有异常及其类名、消息和堆栈跟踪是很有用的,就像常规 Java 那样。

我已经尝试在错误页面中自己打印异常,但剥离发生在调用错误 View 之前。

是否有可以改变这种行为的配置参数?

编辑:我有 posted a bugstarted a mailing list thread ,但到目前为止我还没有找到解决方法,甚至还没有找到 Grails 源代码中发生这种剥离的地方。

最佳答案

试试 this :

You can completely disable stacktrace filtering by setting the grails.full.stacktrace VM property to "true" i.e. add the -Dgrails.full.stacktrace=true option to your application startup script.

关于exception - 为什么 Grails 会删除我的异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27572062/

相关文章:

jquery - 无法在 Grails 中使用 javascript 变量作为属性

java - 如何使用 Joda-Time 计算从现在开始耗时?

logging - 有没有一种干净的方法来记录 Groovy 中方法的结果?

groovy - 为什么像 'center' 、 'contains' 这样的方法在字符串上不推荐使用?

java - 为什么Gradle编译.java文件而不创建我的.jar?

java - Spring异常处理程序,无法访问请求属性

Java RSAPublicKey 工厂异常

c++ - 如何从 C++ 引发将触发脚本异常处理程序的异常

java - Spring boot 中的枚举绑定(bind)异常处理

hibernate - 获取具有特定权限的人员-带有Grails的 Spring 安全