Difference between revisions of "Error Handler"

From PresenceWiki
Jump to: navigation, search
 
Line 24: Line 24:
 
* 4) Send Email
 
* 4) Send Email
 
* 5) End of Task
 
* 5) End of Task
 +
 +
 +
See also: [[Throw Exception]] Node.

Revision as of 16:06, 29 March 2010

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.