Basic error handling in Pega
Generally speaking we come across 2 types of errors
1. A step fails (For example trying to do Obj-Open-By-Handle and giving an incorrect handle)
2. An Exception occurs (This could be due to many reasons, eg: setting a text value to a parameter of type integer)
If no exception handling is applied pega’s behaviour is like this
1. A step fails:
I have 2 activities
- DoAnythingActivity
- TestActivity
DoAnythingActivity calls TestActivity and in TestActivity a fail occurs
Running the activity we get error
In the tracer we see the error happens in step 2 of test activity, BUT all the steps after that are executed
ALSO In the calling activity we can see the TestActivity ends with the status FAIL. All steps of calling activity are also executed.
2. Exception occurs:
For testing exception we add this step
Running the activity we see
Here is the tracer:
We can see both the activities DO NOT execute fully, and end as soon as the exception occurs
For exception handling:
1. When a step fails
After the fail in 2nd step we directly go to 4th step and in the calling activity since we have not applied any error handling all steps are executed
2. Exception occurs:
After running the acitivity we see now the outcome is not so bad, we directly go to step 5 in called activity (and not 4) because exception occurred and all steps of calling activity are also called.
Important: Now in the calling activity StepStatusFail will give true, but ‘On exception, jump to later step label’ will not as it is already handled in the called activity.
If I keep this empty in called activity
We again get the same bad result
If called activity is not handling the exception then the calling activity will handle it if ‘On exception, jump to later step label’ step label is given.