不确定 UML 2.0 活动图中的异常处理

发布于 2024-10-12 02:58:08 字数 839 浏览 2 评论 0原文

你好, 最近我正在对某个项目进行UML逆向工程,并且陷入了无法得出结论的地步。代码相当简单:

            ...
            try
            {
                sj = SendingJob.DeserializeXmlString("....");
                trcSrc.TraceInfo("....");
            }
            catch (FormatException)
            {
                trcSrc.TraceError("....");

                return "00 - Job Content Bad Format.";
            } ...

首先,我将代码建模为:


alt text


但在阅读以下文本后:

“如果在执行操作时发生异常,则执行将被放弃,操作不会有任何输出。如果操作有异常处理程序,则使用异常信息执行处理程序。当异常发生时handler 执行后,其输出可用于受保护节点之后的下一个操作,就好像受保护节点已完成执行一样。"

...但问题是我的异常处理程序通过返回一个值并停止活动来退出 catch 块。我尝试将异常节点链接到活动最终节点,但我的工具拒绝这样做,而且我很确定这不是正确的方法。

所以我的问题是: 如何对活动图进行建模,其中操作抛出异常并且其处理程序终止活动?

HI,
I recently was reverse engineering a certain project to UML, and was stuck at a point where I could not reach a conclusion. The code is fairly simple:

            ...
            try
            {
                sj = SendingJob.DeserializeXmlString("....");
                trcSrc.TraceInfo("....");
            }
            catch (FormatException)
            {
                trcSrc.TraceError("....");

                return "00 - Job Content Bad Format.";
            } ...

Firts off I modeled the code as such:


alt text


But after reading the following text:

"If an exception occurs while an action is executing, the execution is abandoned and there is no output from the action. If the action has an exception handler, the handler is executed with the exception information. When the exception handler executes, its output is available to the next action after the protected node, as though the protected node had finished execution."

... but the thing is my exception handler exits the catch block by returning a value, and stopping the activity. I tried to link the exception node to an activity final node, but my tool refuses to do it, and which I'm pretty sure is not the correct way to do it.

So my question is:
How to model an activity diagram where an action throws an exception and its handler terminates the activity?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

壹場煙雨 2024-10-19 02:58:08

由于我还不允许发布图像,因此我将尝试描述我的解决方案:)
在异常处理程序中,包含一个表示其功能的操作。然后,您可以将该操作链接到活动图的终止节点。

As I am not allowed to post images yet I'll try to describe my solution :)
In your exception handler, include an action that represents what it does. You can then link that action to the termination node of the activity diagram.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文