In a Scope Activity made in C#, I would like to prevent any exception to propagate to upper layer, a bit like the native try/catch activity.
Here is my code :
protected override async Task<Action<NativeActivityContext>> ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken)
{
// Inputs
return (ctx) =>
{
// Schedule child activities
if (Body != null)
ctx.ScheduleAction<IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted);
};
}
Inside OnFaulted :
private void OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
{
Console.WriteLine("OnFaulted");
hasEncounteredException.Set(faultContext, true);
exceptionMessage.Set(faultContext, propagatedException.Message);
faultContext.CancelChildren();
Cleanup();
}
When I simulate an exception inside this scope activity, "OnFaulted" is displayed but then the RemoteException wrapping get my exception. How can I inside OnFaulted or inside ScheduleAction indicate to UiPath to not propagate the exception and to continue the next activity as if everything is fine ?
Thanks for your help