Isaac Yuen Isaac Yuen - 1 month ago 30
C# Question

How to catch a toomanyattemptsexception in botframework

I was just playing with the PromptNumber dialog. I tried to enter gibbish in the dialog and once it exceeded the number of retry, the bot replied 'too many attempts', and replied 'Sorry, my bot code is having an issue.'. I looked at the code and the bot is throwing TooManyAttemptsException, but I do not know the right way to catch it. Need some help in this async code.

"Give a positive integer",
"Didn't get that!");
catch(Exception e)
await context.PostAsync("Too many attempts. Please start over again.");




You have to do the catch in your AfterSetMaximumAsync method. Just wrap the await of the result with a try / catch.

Here is an example.