title: How to fix "'throw' of exception caught locally"?
body: <p>In this function that handles a REST API call, any of the called functions to handle parts of the request might throw an error to signal that an error code should be sent as response. However, the function itself might also discover an error, at which point it should jump into the exception handling block.</p>
  
  <pre><code>static async handleRequest(req) {
      try {
          let isAllowed = await checkIfIsAllowed(req);
          if (!isAllowed) {
              throw new ForbiddenException("You're not allowed to do that.");
          }
          let result = await doSomething(req); // can also raise exceptions
          sendResult(result);
      } catch(err) {
          sendErrorCode(err);
      }
  }
  </code></pre>
  
  <p>Webstorm will underline the <code>throw</code> with the following message: <code>'throw' of exception caught locally. This inspection reports any instances of JavaScript throw statements whose exceptions are always caught by containing try statements. Using throw statements as a "goto" to change the local flow of control is likely to be confusing.</code></p>
  
  <p>However, I'm not sure how to refactor the code to improve the situation.</p>
  
  <p>I could copypaste the code from the <code>catch</code> block into the <code>if</code> check, but I believe this would make my code less readable and harder to maintain.</p>
  
  <p>I could write a new function that does the <code>isAllowed</code> check and throws an exception if it doesn't succeed, but that seems to be sidestepping the issue, rather than fixing a design problem that Webstorm is supposedly reporting.</p>
  
  <p>Are we using exceptions in a bad way, and that's why we're encountering this problem, or is the Webstorm error simply misguiding and should be disabled?</p>