Basic Rules

Typically, you wrap a Try/Catch block around your functionality so that all unexpected situations flow down into the Catch block.

Try   --> whatever (unexpected) happens here
Catch --> will be handled here

Typically, you wrap a Try/Catch block around your functionality so that all unexpected situations flow down into the Catch block. There are some common patterns which are used independly of the programming environment or language.

  • DO use only one Try/Catch block per function / process

  • DO NOT handle unexpected situations as part of your business logic (for example, in a sub-process). Whenever you are coming across a situation in your logic, where you do not know how to recover you throw an Exception or let the Exception happen.

Anti-Pattern

WRONG: A sub-process catching and handling an exception: sending an e-mail.

RIGHT: Only the top-level process implements the exception handler (Catch block), while the sub-process let Exceptions happen.

Last updated