Exception Type Not working within Try Catch

I know this will probably be a quick fix, but i am stumped right now…

I have a small part of my larger process that reads an excel into a DT then uses DT.select to assign a variable with the data held in column 2 based on the email address within column 1… Obviously works fine until there isn’t a matching email address within the excel file… I’m trying to put the failing part of the process within a try catch, however when i run it despite it failing for an index outside the bounds of the array it doesn’t like my indexoutofrange exception to continue the process and send an email showing the error…

Is there another exception anyone can suggest i use…?

Thanks in advance

@DawnW You can use System.Exception which will catch all exceptions that will be thrown in the try block

1 Like

It still come up with an error of index was outside the bounds of the array when i use system.exception

@DawnW Oh. Then that might be just a Bug.

  1. Restart Studio and Check if it is able to work.


  1. Copy the whole Sequence present inside Try Catch and delete that Try Catch. Use a new Try Catch and paste the Sequence you copied and check if the error pops up again.

Unfortunately i tried both and it still came up with the same fail…

i even re-wrote the details within each of the assigns etc as I have had a bug before with an assign that was corrected by re-creating it (despite it being exactly the same)…

It is very frustrating…

@DawnW Maybe we can use an if Condition instead of Try Catch. Can you tell us what is the Expression you have used in those two Assign Statements.

Also open a new xaml file (Basically a new Sequence from the Top Design Ribbon) then try to use Try Catch in it and check

Checks the email address within variable Testt against column eMail in an excel file and returns the value in the next 2 columns into 2 new variables:
DTSender.Select(“eMAIL= '”+Testt+"’")(0).Item(1).ToString
DTSender.Select(“eMAIL= '”+Testt+"’")(0).Item(2).ToString

Recreated this small part of the process in a seperate xaml…
It works if the email address is correct, but not when there is no email address match…

@DawnW Try these Steps :

  1. Create a DataRow variable, say dtArray.

  2. Use the Below Expression in Assign Statement :
    dtArray = DTSender.Select(“eMAIL= '”+Testt+"’")

Use an If Activity with the Condition as dtArray.Any

In Then Section, use an Assign Activity in the below way :
FileStart = dtArray(0).Item(1).ToString

You can then perform the same steps for other variable

@DawnW So the Try Catch doesn’t work :sweat_smile: Make sure all the dependencies are updated to the latest package.

My assign activity is showing a compiler error:
value of type ‘1-dimensional array of system.data.datarow’ cannot be converted to ‘system.data.datarow’

I set up the variable dtArray as a datarow type all my other variables are string

@DawnW The type of dtArray should be Array of DataRow :sweat_smile:

I’m clearly having a very bad day… Maybe I should just go home…

@DawnW Do not worry so much. Be positive always, there may be mistakes but we always learn from our mistakes, and I clearly like making mistakes as well :sweat_smile:

Although it shouldn’t be repeated

Also what happened while converting the variable to Array of DataRow ?

I tried your option B with the IF statement as that way of doing it really intersted me in getting that to work too… Unfortunately my assign of dtArray came back with the following error:
My build of DTSender all columns are string

I’m clearly missing something, sorry…

@DawnW Ok. Can you tell me what does the testt variable contain ? We can go for a more advanced Linq query.

Also can you show me some data in that Datatable just so I can confirm what I should do ?

At the moment it is only the result of an assign activity (string)
Testt = “@optima.co.uk


@DawnW Are you using read Range to get the Output form the Excel File ? If so, Why do you need the Build Datatable ? What is the Datatable variable used for Build Datatable and datatable used for Read Range ?

They are both DTSender…
I’m not sure why i have both… This was a part of the process that i wrote a long time ago…
I will delete out the Build and just use the Read range to populate the DTSender…

1 Like