R – Workflow and exception handling

exceptionworkflow

In developing a custom workflow that will execute numerous work items, it is possible that one or more workitems could fail at any time during their routines and even perhaps raise exceptions.

What is best practice when it comes to handling exceptions raised by workitems inside a workflow manager?

For instance, should the workflow management system simply just log the error and then die outright? Should the workflow manager simply log the exception and carry on with execution of other workitems?

Best Answer

I would say that this is very context dependent.

Pack parcel

Dispatch parcel

Surely a failure of step 1 must not be followed by execution of step 2?

Check price with vendor A
Check price with vendor B
...
Check price with vendor Z

Buy cheapest

Proabably a failure of a few of the price checks shouldn't prevent the overall completion.

I think you will need to enable at least

Park this for human intervention

and

Sorry your request could not be actioned. 

But this gets very tricky. You may need to enable compensation (undoing previous work). For example Book Hotel, try to book flight - fails, hmm not enough just to abort we also need to unbook that hotel.

You may also need to enable

That failed, I'll retry a little later.