TryCatch - TextNotFoundException

TryCatch

Hi, I’m using a TryCatch to catch TextNotFoundException activity. I would like to write to a text file when the text is found. By default the TextNotFound Catch displays ‘exception’. How do I flip it so when the text is found it is logged to a string in the text file. Right now it is writing the exceptions to the file as expected.

Hi @kenneth.gilpin,

Please help me to understand your question, you want to write the text found in the text file and when its not found it should log it in another/same text file . Correct me if I understood wrong.

Hi,
It writes to the text file as a string- row(“lname”).toString + “, " + row(“fname”).toString +”- Was not found. " - for the exceptions.

I tried writing to two different text files, I just got duplicates. Ultimately I just want to write the row that was successfully found in the Try. Hopefully that makes sense.
TryCatchExcept

Thanks @kenneth.gilpin,

In Try block use an If activity check if “lname” isnot nothing and “fname” isnot nothing then use append activity to write into the file . and in else you can throw an exception text not found so that the control flow will come to catch block.

I hope it will help you.!!!

It worked. Thanks so much. I had tried a If before but did not have the condition properly defined.

Thanks again.

1 Like

you are Welcome!!! pleasure is all mine. :slight_smile: