Try and Catch on Web Pages

Hello, I have a process that do some activities on a web page and I want that if an error occurs in the process to catch that error and send an email to the user.

I put an try and catch and in the try i put the sequence with the web process and in the catch I put the send email activity.

But if an error occurs the workflow don’t catch the error.
Do I need to use a specific exception?

maybe better to set the exception type to the more general System.Exception. Currently it is only configured to IOExceptions often in relation with filesystem exceptions

Hi

You are only catching one type of exception type “IOException”

If you use “System.Exception” it will catch all exception types.

So create a new Try catch and insert System.Exception to catch all exceptions.

Within the Catch insert:
a Log message at Error level with the following text (update accordingly):
"Failed at the web process stage. Exception mesage: “+Exception.Message.Tostring+”. Exception Type: "+Exception.GetType.Tostring

The ‘exception.GetType’ will tell you the exact type of exception. You can then review the type and add specific catches in later version to suit your needs like the ‘IOException’ type.

Then insert your mail activity.

Here is a tutorial

Hopefully this helps :blush:

Cheers

Steve

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.