Skip to main content
Anyone up for providing a quick tutorial and best practices on exception/error handling? I know that you can "enable exception handling" and view code to write code to deal with the error.  My main problem is that the process then falls into error state.  I would like to build somewhat "self healing" processes.  For example, if the call to the web service is down fall back to the default values or try another web service...  How do I do this and what are some best practices for dealing with errors in processes? 

From my experience with the K2 platform, this approach can lead to problems if not handled carefully.  While a particular workflow instance is executing in a thread inside the K2 server, it is obviously consuming resources.  You could wrap the code in something like the following:

boolean blnExceptionOccured; 

int count = 0; 

do
{
count++;
blnExceptionOccured = false;
try
{
//PUT K2 CODE HERE
}
catch(Exception eX)
{
if(eX.Message == "some error")
{
blnExceptionOccured = true;
}
}
} while (blnExceptionOccured == true && count < 5);

Obviously, this would need to be fleshed out more for the specific cases.  You should write some type of log message (our API provides that) out each time the catch block executes.  Be careful to ensure that the exception will not cause the workflow instance to go into an infinite loop.  Another approach would be to notify a specific resource via email, like a K2 systems administrator, to review errors when they occur.   I will do my best to follow up this post with more details on how to accoplish these things. 

Regards,
Sam


Hi Sam,

Did you ever follow up on this? I would also be interested in more ideas on exception handling - I can't seem to find any best practice guides on this (however this doesn't necessarily mean they don't exist - it is very difficult finding anything on the k2 underground site at the best of times)

Thanks in advance!


Although I don't believe it answers the original topic exactly have you taken a look at the K2 blackpearl Best Practices document?  This document does contain a lot of useful information and some examples on exception handling within blackpearl.  Specifically with exception handling it covers how to get process or activity context information when handling an exception.


Its available at:  http://help.k2.com/en/KB000352.aspx .  Note you will need a K2 Portal account to access this document.


Hope this helps.


Tim


hi

 

I am a .net developer and new to K2.

 

I want to implement exception handling which would fulfill the following aspects

 

  1. Make it as generic process can be used as it in anywhere
  2. Should take care of notification with complete details of error
  3. should have capability to retry ( based on configurable times)

and create task to Admin to perform manual retry

 

for technical errors build some frameworks in Visual studio create custom code snippet with possible errors and catch and thrown back to calling event

 

 

 

Anyone please provide the way to implement this


Reply