如果你把它放在一个 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 bug和 started 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/