How I draw a try-catch in a sequence diagram

There is no standard way to model exception handling in a sequence diagram. However, exception handling is often critical. Here is how I visualise it. Remember, you can take quite some freedom in using UML. It is a language and as such it changes in lifetime. As long as your reader gets the idea you want to express, everything is perfect.

A typical exception handling logic
The above diagram is generated with Web Sequence a free (open source) chrome extension. You can get it from here: http://bit.ly/web-sequence-ws or from the official site: http://bit.ly/zenuml.

To test it out, you can simply paste the following code into the code editor of the above plugin or on the site.

JobTask.Run() {
try() {
Action.Execute() {
InternalException.throw()
}
}
InternalException.Catch() {
Logger.Error()
HighLevelException.throw()
}
}

It demonstrates that we have a try block. Within this block, we execute Action.Execute() in which InternalException could be thrown. Then we catch it, log an error and rethrow a HighLevelException, which is a quite typical exception handling strategy.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.