Custom Activity - Errors Best Practice

After looking at some examples and browsing the forum I could not find much information on how to handle errors in side an execute method.

For example, I go to retrieve something and it is not there. At this point the activity can not complete. What is the best practice at this point, throw an exception or just set the cancel status

Thanks


Answer this question

Custom Activity - Errors Best Practice

  • Dan S

    This helps little. However what is the recommendation when you do not know how the activity is going to be used i.e. creating an activity for use by others. If there is going to be third party activity market how should errors be handled by the activity writers. You almost need another status coming from the activity like error So the activity never lets an exception out but the workflow knows that an error has occurred.



  • Uwe Keim

    In this case it really depends on your workflow scenario.  If the library is known to possibly throw an exception or if the resource is known to not necessarily be available during Execute, I would probably catch inside Execute and retry, if appropriate. 

    The only time you would want to let a known exception escape Execute is if you want the workflow author to specifically catch the exception.

    Hope this helps Rabi.

    Arjun

  • Floele

    The scenario is accessing a resource which may or may not exist, be accessible, or otherwise not available at the moment the activity is executed. Another example is that the underlying activity calls a library function which throws an exception.



  • _ross

    RSatter,

    If the exception thrown by Execute() is not something that you expect workflow authors to explicitly catch via an exception handler, then you should cancelling or closing the activity would be more appropriate.  What's the specific scenario for the custom activity you're creating

  • sunzhoujian

    Returning a status of Cancelled will indicate the activity was not successfully completed; whereas returning a status of Closed will indicate the activity completed successfully.

    If you cancel, subsequent activities in the flow will be allowed to execute.  If you throw, the workflow will terminate unless the exception is caught.

  • Custom Activity - Errors Best Practice