Friday, August 31, 2012

Exception handling in Pega Activities

Exception handling in java methods can be done in many ways. We can log the reason for the exception, the respective stack trace and we can even manage to print the stack trace to your application specific logs(java does that by default though) explicitly using Reflection API or many other mechanisms.

Pega also have such mechanism to exception handling in Activity rules. This can be done using standard when conditions named StepStatusGood and StepStatusFail(in @baseclass) in transitions of activities. These when conditions internally uses pxMethodStatus property to validate whether the execution of the particular step is successfull or failure. pxMethodStatus property will be updated regulary with the status after end of each step execution and before the start of the next step execution.

We also have a boolean named hasMessages which informs you whether a page contains one or more page messages. Any page which has one or more messages are treated invalid page in pega and cannot be persisted.

But, one very important missing point here is, the actual error message will not be found any where at design time. That is, there is no such property pega provides to hold the error message of the exact reason for the exception or the step failure. One has to dig into the logs or tracer to find out the error reason. This is really uncomfortable while developing applications. There is no any out of the box property that holds the the error message of the exception. It sounds so ridiculous why such a basic thing is not provided in pega?

A bit of R&D showed me this. An activity ActivityStatusExceptionHander in @baseclass handles the error message displaying in the window like this,


Digging into this activity showed me that, a property pyMessageLabel is the property which gets to hold the error message in case of exception. But after the harness display, the page which holds the pyMessageLabel is being deleted. So, if you want to customize the functionality you have to save this ActivityStatusExceptionHander activity to your local rule set and try on to hold the error message and you can play around.

Feel free to contact me if i'm missing anything.

2 comments:

Hirananda said...

Exception handling in pega can be done via Tickets as well as Activities using when in the transitional step which can decide whether proceed to another step or stop with a particular message based on a condition

Anonymous said...

exception Hndling by "Jump" is missed