title: How to avoid "Sorry, my bot code is having an issue" in Microsoft Bot Framework
body: <p>I have a bot that runs on Azure + Bot Framework + LUIS (via LuisDialog). </p>
  
  <p>If the user happens to send two messages in a quick succession (before the bot has a chance to answer), they see this error message on their Facebook Messenger or web embed: </p>
  
  <blockquote>
    <p><strong>Sorry, my bot code is having an issue.</strong></p>
  </blockquote>
  
  <p>When debugging through bot channel emulator, I see that the error is this:</p>
  
  <blockquote>
    <p>"text": "Error: Response status code does not indicate success: 429
    (Too Many Requests).    at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)
      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)
    Microsoft.Bot.Builder.Luis.LuisService.d__4.MoveNext()</p>
  </blockquote>
  
  <p>The end of the stack trace shows that the error originated at this line in my MessageController.cs: </p>
  
  <pre><code>await Conversation.SendAsync(activity, () =&gt; new LuisRootDialogEnglish());
  </code></pre>
  
  <p>This is weird because I'm using a paid version of LUIS which allows up to 10 calls per second.</p>
  
  <p>In any case, I tried wrapping the whole code in MessageController.cs into a <code>try/catch</code> block, and returning this value regardless of an exception:</p>
  
  <pre><code>return Request.CreateResponse(HttpStatusCode.OK);
  </code></pre>
  
  <p>Still, the users see the error message "Sorry, my bot code is having an issue" which basically means there is an unhandled exception. </p>
  
  <p>How can I prevent this message from being shown to users, or catch the exception? </p>