Handle Webclient Exception
Hi I am making a number of requests to map/geometry services from my workflow particularly using QueryTask and BufferTask. I am trying to handle exceptions in a Try/Catch. I have tried HttpException, WebException to catch Http issues for example unable to reach service, service/server not available, but these are not being handled.
System.Exception does work but the stacktrace does not provide any meaningful messages about the error e.g.
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Geocortex.Workflow.Activities.QueryTask.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)</Message></Event>
Any suggestion whats the best way to handle webclient exception in the workflow..
0
-
Hi Ravin,
The QueryTask and BufferTask activities implement the AsyncCodeActivity class:
https://msdn.microsoft.com/en-us/library/system.activities.asynccodeactivity(v=vs.110).aspx
The actual web request made by these tasks is done asynchronously. If the buffer or query task fails, we do try to set the exception, but if the exception would interfere with that failure code it may bubble up when the tasks finishes executing.
Your stack trace here appears to be caught in the EndExecute method, which means that the task itself either does not know what has happened, or that the task was canceled (perhaps an execution timeout?)
There may be an InnerException property in the Exception you catch that might contain more information. Unfortunately, we may not be able to get more information from this operation, since we are not able to block the web server process in a server-side workflow to fully catch the error.
I like to use the Log activity to keep track of server-side behavior - you may be able to avoid your exceptions by adjusting the way you issue queries or buffers, especially if you can determine if it's a timeout or a data size issue.
Regards,
-Malcolm0
Please sign in to leave a comment.
Comments
1 comment