Try Catch, Error Handling with Input Dialog Box

Hello Everyone,

I am trying to make an automation where in I will make the user to input words into a Input Dialog Box, then output the result to a message dialog box. But also I wanted to put certain catches when ever the user puts null on the input box or even close the box itself.

I have tried putting try-catch but doesnt catch any exception, it just go directly to the “finally” block.

Please see attached XAML. Main.xaml (8.5 KB)

I really want to learn about this.

Thank you.

1 Like

@pasimon

it is because the message box is working properly, you need throw if you want do that.
Please refer my xaml and try-catch description.


Main.xaml (11.4 KB)

Rgds,

J,

2 Likes

Hi,

I have tried this. Thank you very much. But how about for example the user didn’t put any values again? How can automation throw another catch block?

Hi,

Actually, I’m not quite sure what you would like to do. If you would like to ask user to enter the value if that is blank, then you need to use flowchart and flow decision instead of Try-catch… If something wrong, plz let me know what you want to do.

@pasimon

Create one output variable of type string for Input dialogue box activity and say ‘readInput’

You can check Null values like this.

      String.IsNullOrEmpty(readInput)

And also you can check length of it.

  readInput.Trim.Length > 0 
  Then they entered input
   Else they entered null value.
1 Like

Hi, @Jumbo.

For example…

Try
First Input > User entered null > Throw to catch block

Catch
Second Input > “Accidentally” user entered null again (it must be throwed again to a catch block)

Apologies if I can’t explain it that well.

@lakshman

Already got it, thank you for this. :slight_smile:

1 Like

Please once check this, I changed your logic and I assume this is what you want to do, isn’t it?
flow.xaml (13.2 KB)

Actually, I don’t understand why it is try-catch… :slight_smile:

1 Like

Hi @Jumbo,

Thank you so much for this, my mind was stuck only in using sequence thats why. This is a great help. :heart_eyes:

Thank you!

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