Try Catch error issue

Hi, I have used 2 Try Catch activity in the same sequence,
Now in the first Try Catch I am opening the browser and Login to the Portal. In the second Try Catch I am checking the Result.

I have ran the bot in a normal mode only.
The browser page not opening and it’s moving to the Catch block of First Try Catch,
when it executing the 2nd Try Catch it thrown the exception in the Try Block and stop the bot there only if there is exception Catch should executed.

@Palaniyappan @lakshman

@balkishan

In second Try Catch block, which exception you mentioned ? Is it System Exception ?

And also show me screenshot of error you are getting.

1 Like

No other exception I have mentioned bro.

some web related exception.

Bro, could you please how to identify which type of exception we have to use.
But it’s a web page related exception, so do we need to use the System.Exception here ?

**But now it’s working bro, when I set the System.Exception. **

But I want to know so when we have to give the different - 2 exception type. ?

Fine
i hope the second set of sequence in TRY block in second try catch activity will get executed only when the sequence in the first TRY CATCH activity gets executed successfully
…so keep the second set of activites inside the TRY block of FIRST TRY CATCH ACTIVITY Itself
that is dont create second TRY CATCH block and put that set of sequence

Cheers @balkishan

1 Like

@balkishan

System.Exception will catch any type of exception. If you know what type of exception it will give then you can use corresponding exception type else use System Exception.

1 Like

Hi Palani, I have to handle the many exception, If I put everything one Try Catch, then it will show me the one error, how do I know where is the error, like the error is opening browser, or login to the credentials or checking the result. Like this.

I am checking the result on the web page, So I have to handle that one only, If the page not loaded properly. just thrown exception.

Fine in that case put the second TRY CATCH activity inside the FINAL block of first TRY CATCH activity and try once

Cheers @balkishan

1 Like

@balkishan

For this, you can use System Exception and in Catch block use Log Message activity and print this value.

    Exception.Message
1 Like

Bro in second Try Catch I am checking the result, so I the first Try Catch login successfully, then it will not moving into the Catch block right??
So bot will not check the result here, bcz in second Try Catch I have used the check result activity. So confused bro.

And one more, In the first Try Catch block the portal is taking time to reload, but bot execute the Catch block. bcz it’s not waiting for the portal to load fully and login. So how to handle this exeption also. I want my bot wait till the page open and login, If the site is not working then I want to execute the Catch block. @Palaniyappan @lakshman

ah i have changed in the previous comment
–like in the first TRY CATCH activity with CATCH block include the same sequence of activities that we have in the TRY block so that it will perform again the same set of sequence.
and in the FINAL block include the second TRY CATCH activity with the sequence you have
now, as the FINAL block will get executed always

and for this
use ELEMENT EXISTS ACTIVITY and get the output with a variable of type boolean
and use a if condition like this booleanvariable = True
if true it will got to THEN part or to the ELSE part where include a THROW activity with a exception statement like this
new BusinessException(“your exception message”)
so that it will take us to CATCH block

Cheers @balkishan

1 Like

I really don’t understand this bro.

I understand I have to use the Second Try Catch inside the First Try Catch Final Block. Now
Element Exist Activity I have to use in Try Block Of Second Try Catch Right??

If yes then It will give me the True/False result. So If condition where I have to use. you mean in Catch Block of Second Try Catch Activity??

And second question also like If I am checking the opening portal and login in First Try Catch activity. And same sequence I have put in Try and Catch block. Assuming in Catch my login got successfully then it will executed the Final that I got. and it’s fine.
Now suppose side is not login in Try block and when it try for second time in Catch block again it failed to login. So this error how do I show??? Hope you understand bro.

@Palaniyappan

no no
the element exists has to be used in TRY block in first TRY CATCH ACTIVITY and next to that use IF and THROW activity inside the ELSE part so that if any exception occurs it will go to CATCH block where we are now having our set of sequence to be performeed
once after that it will get into FINAL block where we have our SECOND TRY CATCH activity

Cheers @balkishan

1 Like

Now I understand, so this If condition I have to give in the Catch Block of First Try Catch Activity right?

1 Like

no in the TRY block of FIRST TRY CATCH activity, as your need looks like that

Cheers @balkishan

1 Like

Okay got it bro. So for this which property of Wait for Ready I have to select and the timeout value also. See bro sometime it’s takes 2 min sometime it open in 5 sec also, So I want to make dynamic only once the element found then it proceed with the second step.

1 Like

Fine
in that case set for the maximum value like around 180000 milliseconds (3 min) and wait for ready property set with COMPLETE

Cheers @balkishan

1 Like

Thanks Palani it’s working bro :slight_smile:

1 Like

Cheers @balkishan

1 Like

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