Error Handler

From PresenceWiki
Jump to: navigation, search

Error Handler Node

Many things can go wrong when a Task runs as there is a lot of dependency on external systems such as databases. It is good practice to anticipate such problems and deal with them correctly.

This is where the Error Handler Node comes in. Two branches lead away from this Node: A "Try" branch and a "Catch" branch. The "Try" branch is executed first. If anything goes wrong (generating an exception), execution will be deferred to the "Catch" branch and the details of the error will be placed in the Presence Context.

Here is an example of a Task with an Error Handler node:

Error handler task.png

Here is the order of execution assuming everything works as it should:

  • 1) Start of Task
  • 2) Error Handler
  • 3) Query Customers (succeeds)
  • 4) Send Email
  • 5) End of Task

But what if the database being queried in the third node is down for maintenance? This will result in the Query Customers node throwing an exception. Ordinarily, this would result in the whole Task failing and it would be retried at the earliest opportunity. But that's not the behaviour we want - if the database fails, we want an email to be sent to the Database Administrator, and the Error Handler will deal with this for us:

  • 1) Start of Task
  • 2) Error Handler
  • 3) Query Customers (fails)
  • 4) Send Email
  • 5) End of Task


See: Throw Exception Node.


See Also

Task Elements > Flow Control Task Elements > Error Handler

Schedule Nodes | Decision Point Nodes | Start of Task | End of Task | Error Handler
Throw Exception | Passive Node | Log Entry | Sleep For n Seconds | While Node | Loop Node | Exit Loop Node | |Switch Node
Fork Execution | Join Forked Threads | Start Synch Block | End Synch Block | Event Notification Nodes



Task Elements | Resources