UML Exception Handler Notation

Viewed 571

What is the notation for an Exception Handler in UML activity diagrams? Is it just the lightning bolt? Or more than that?

According to the specification v2.5.1 page 404:

An ExceptionHandler is shown by drawing a “lightning bolt” symbol from the boundary of the protectedNode to a small square on the boundary of the ExceptionHandler.

To me, this sounds like a recursive explanation.

According to the abstract syntax (page 403), exception handlers are part of their protected node and are associated to the handlerBody (ExecutableNode), the exceptionInput (ObjectNode), and to exceptionTypes (Classifier).

My understanding is, that the exception handler is just the lighning bolt. The handlerBody, its objectNode, and the protectedNode are separate entities using their own notation.

Is someone able to clarify this?

3 Answers

The wording in the specs is sometimes confusing. The lightning is an InterruptFlow and the handler is an ExecutableNode. There are quite some examples in the specs (pp. 403 of UML 2.5)

You need four things to show exception handling in an AD:

enter image description here

  • Some Action (I left out control flows from/to other actions)
  • An InterruptibleActivityRegion (the dashed boundary)
  • An ExceptionHandler with a ObjectNode to accept an exception
  • And the InterruptFlow (shown by the bolt)

You can only have the bolt go out of the interruptible region. And like usual object flows you can attach guards to that bolt.

In order to show details of the exception handling you can place call behavior inside the handler.

To specify exception types you can do it as shown in the specs on p. 403 of UML 2.5:

enter image description here

You are right the Abstract Syntax seems more clear than the description for me.

Exception Handler might be see like an edge. It is owned by its source, aka the protectedNode for the Exception Handler, and referring its target, aka the exceptionInput (owned by the handlerBody) in the Exception Handler case.

Of course in most of the case the protectedNode and handlerBody are two differents Executable Node with their own notation (Structured Activity, Action ,etc. ).

Last point is the exceptionType Classifier which is a reference to any Classifier on your model.

Hoping it clarifies things. EBR

You are right - ExceptionHandler is a lightning bolt.

According to the Abstract Syntax diagram below, ExceptionHandler is an Element that represents a relationship between four other instances: ExecutableNode (protectedNode), ExecutableNode (handlerBody), ObjectNode (exceptionInput) and Classifier (exceptionType)

enter image description here

So the documentation is mostly precise (with my minor modification - I replaced the second ExceptionHandler with handlerBody):

The notation for ExceptionHandlers is illustrated in Figure 15.62. An ExceptionHandler is shown by drawing a “lightning bolt” symbol from the boundary of the protectedNode to a small square on the boundary of the handlerBody. The name of the exceptionType is placed next to the lightning bolt. The small square is the exceptionInput node.

enter image description here

Related