Jun 11, 2015

Exception handling – Process failed status in Asynchronous process

We discussed about handling of exception of plug-ins in few occasions. We also discussed and   recommended the usage of tracing mechanism and you can check it here.

It could be important to show a formal message to the user if a process is failed, especially in Asynchronous processes because it doesn’t throw any exception as in synchronous processors. User may not have sufficient permission to check system jobs either. Tracing information is not for end users, but for developers. In this case, we can use a custom status field with one value as process failed.

Please check the code snippet and notice how that status change happened just before exception is thrown.

try
{
  //Any information you need to trace
  // ex;
  //tracer.Trace("Account:{0} and Guid:{1}", _account.Name, _account.accountid);
}
catch (Exception ex)
{
  // ***status change to Failed status ****
  throw new InvalidPluginExecutionException("[" + ex.Message + "]" + ex.StackTrace, ex);
}
finally
{
}

Now, this worked fine for lengthy processes for me. Yet, there is one exception: if issue occur with SQL time out/ DB connection this will become a problem. Why? Simply this update won’t happen and system will stuck in that point… bitter truth is we are not getting any trace information either, because it come after this step.

So you need to decide depending on your scenario. If the SQL time out is a possible culprit, just forget about this status change.

No comments:

Post a Comment