Error Handler

From PresenceWiki
Revision as of 11:06, 29 March 2010 by Mattpryor (Talk | contribs)

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:

http://www.international-presence.com/wikidocs/images/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 also: Throw Exception Node.