简体   繁体   English

Grails WebFlow错误处理

[英]Grails WebFlow Error Handling

Is there any easy way how to handle errors in the Grails Spring WebFlow in general? 有没有什么简单的方法来处理Grails Spring WebFlow中的错误? I mean not to have a try-catch block in each block but to have a general handler for the whole flow. 我的意思是不要在每个块中都有一个try-catch块,而是要为整个流程提供一个通用的处理程序。

We found one solution to put some logic to error controller (accessed by mappings "500"(controller: "serverErrors", action: "error500") ). 我们找到了一个解决方案,将一些逻辑放到错误控制器上(通过映射"500"(controller: "serverErrors", action: "error500") )。 But it's not sufficient way fur us because the exception is thrown anyway. 但这并不足以让我们感到厌烦,因为无论如何都会抛出异常。

We'd like to catch SnapshotNotFoundException which occurs when the user manually change the web flow step in url, let's say from ?execution=e4s2 to ?execution=e4s3 我们想要捕获SnapshotNotFoundException ,当用户手动更改url中的web流程步骤时,请?execution=e4s2 ,假设从?execution=e4s2?execution=e4s3

Is there any way how to do it? 有什么方法可以做到吗?

Why don't you add Global transition for Exception? 为什么不为Exception添加全局转换?

<global-transitions>
    <transition on-exception="java...SnapshotNotFoundException" to="..."/>
</global-transitions>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM