可恢复的例外:任何真实的想法,为什么要真正使用它们?

时间:2016-03-02 10:23:27

标签: abap

正如主题所述,我很难想象,在现实生活中如何使用可恢复的例外以及何时使用它们可以获得有效的优势。

我能想象的是,一个子系统已经连接,让我们通过RFC说出一个保持打开状态的会话。子系统必须通过一些shopflor数据传递给sap,让我们说,以通常的方式,处理任何重量/件/升的频率。

不知何故失败了。

我可以在不使用可恢复的异常的情况下完成所有这些操作,因此,除了这个异常似乎跟踪整个上下文(似乎不是一个新功能),是否有任何人有线索这究竟是什么呢?

1 个答案:

答案 0 :(得分:1)

A non-resumable exception is an error of the kind "Something went wrong here, and I can't continue running the program as desired any more. TILT." The caller just has to deal with that.

A resumable exception still tells the caller that something went wrong, but it defers the decision if the program can be continued to the caller. I expect there to be only a few scenarios where this might be useful. Mass updates might be one scenario: "You wanted me to update both the material price and the text; I've changed the price, but the text in language ZH doesn't exist. I don't know whether you'd like to abort the operation entirely (RETURN) or keep the updated price and disregard the missing text (RESUME)."