Allow catching workflow exceptions in the mobile SDK
I'd like to make a feature request for the mobile SDK.
When a workflow is executed from code, and the workflow fails, the SDK will always show an alert with the stacktrace, and the ExecuteAsync method will return null. Here is an example of the code I am using:
try
{
WorkflowArgs args = new WorkflowArgs
{
Url = "https://example.com/portal/home/item.html?id=bcaf8de807f646bb932c9f5bc1289b36"
};
var result = await _workflowOperations.Run.ExecuteAsync(args);
// Alert appears here, after clicking OK, code will continue on the next line
Logger.Debug($"Workflow finished");
}
catch (Exception ex)
{
// This is never touched
Logger.Error($"{ex.Message}", ex);
}
The alert:
Unfortunately, there is no way to prevent the alert, but there are cases when showing it is undesirable. Either because it's acceptable for the workflow to fail silently, or because the error may be better handled in my own code.
A workaround is to wrap the entire workflow in a try-catch activity by itself, but that's somewhat of a hassle, and IMO should not be necessary.
The feature request is to not show an alert, but just (re)throw the exception, so that it can be caught with a try-catch block in the .NET code. Perhaps this could be accomplished with an extra property in the WorkflowArgs parameter, e.g. a bool HandleExceptions.
As an aside, I think that the error and stacktrace that are in the alert don't have much value for the average user anyway, because it's too technical. Having some way to customize this in the Go app would be nice, too.
Comments
0 comments