Try catch in exception handling

How can I catch an exception of my robin script and print something accordingly on my console.
For eg: webautomation.launchchrome has two exceptions LaunchChromeError and InvalidUrlError. I want to catch the exception and depending on the exception write (throw) something on my console.
Is this possible in ROBIN? If yes, then can someone give me the syntax for it.
Thank you!!

Most of the modules have certain exceptions that can be handled within the script.
You can find more information on exception handling from the available documentation.

1 Like

How can I write multiple exceptions within an exception?
eg: on error
if(error1)
statement…
if (error2)
statement…
end
Something like this. I know my example is not possible but I want an exception handling for multiple exceptions for the same action.

@Yash_bitla99 this is supported for the actions that can throw multiple different exceptions according to the corresponding scenario. The Exceptions that can be handled are presented in the documentation at the action properties. Check the ‘Excel.LaunchAndOpen’ action for example:

Excel.LaunchAndOpen Path: 'C:\Spreadsheet.xlsx' Visible:True \
Password:'' \
ReadOnly:False LoadAddInsAndMacros:False Instance=> ExcelInstance
  on error repeat 2 times wait 1 
  on error OpenDocumentError
    set ExceptVar to 'Document does not open'
    goto Exception
  on error LaunchExcelError
    set ExceptVar to 'Excel does not launch'
    goto Exception
  on error
    set ExceptVar to 'General Error'
    goto Exception
end

label Exception
Display.ShowMessage Title: 'Error' Message: ExceptVar \
Icon:Icon.ErrorIcon Buttons:Buttons.OK \
DefaultButton:DefaultButton.Button1 IsTopMost:False \
ButtonPressed=> ButtonPressed

image

3 Likes

@jokoum, that’s a very nice, detailed explanation. Thank you!
Regards,
burque505

1 Like

Thanks alot!!! This will help me alot.

2 Likes