Try Catch - Exception text box

When you create an Exception in a Catch, opposite the Word Exception, is a text box, which defaults to having the text ‘exception’ in it.

Please can someone explain what this text box is for, and what the boxes value means, and what options there are for it?

Hi @aod

The textbox is nothing but to identify an exception what kind of exception is it business exception like that

Ashwin .S

So is it just a free text box, and it doesn’t make any difference to the behaviour what you type in the box?

We need to ensure what exception it is in text box

Thanks, I suppose what I’m trying to understand is, the purpose of the box being there because i can’t find anything that refers to it in the training videos or documentation - so if it defaults to ‘exception’ then does changing it to the word ‘system’, or ‘application’ or ‘banana’ actually affect the behaviour of the program? Will it only accept a valid value, or is it just a free text box, for the information of the person viewing it so they know what type of exception it is?

Assuming you’re talking about this:

That is the name that we give to the exception. If an exception is caught then we can do exception.Message or exception.StackTrace or any other function. If instead we do something like this:
then we would do my_exception.Message or my_exception.StackTrace, etc.

1 Like

The For Each activity has something similar.

This “item” variable can be anything that you want. If you’re iterating through files you can call it file or if you’re looking at lines of a file you can call it line.

1 Like

Brilliant, thank you, that’s exactly what i’m talking about!

So it’s just the name of the exception, then you can refer to that specific one if it’s caught by using it’s name, as if your example above?

Is it a good idea to give each exception a unique name, or just leave as the default name ‘exception’?

Yes, you can refer to it by the name there. Basically, a variable called exception (or whichever name you give it) is created just for the scope of that segment of the activity.

It’s good practice to always name your variables specifically. For the basic Exception case it’s fine to leave it as exception, but if you were catching an ArgumentException I would recommend renaming it to argumentException and so on. It just helps make the workflow a little more readable.

1 Like

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