title: Executing code directly throws exception correctly but within a function doesn't
body: <p>I'm trying to throw exception in the async code. If I throw it directly like this, it works fine. Example:</p>
  
  <pre><code>  Query: {
      requisitions: async (parent, args, { req }, info) =&gt; {
        const user = await Auth.findOne({ _id: req.session.userId }).select('roles')
        if (!user.roles.some(role =&gt; ['driver', 'requestant'].includes(role))) {
          throw new ForbiddenError(ErrorCodes.UNAUTHENTICATED)
        }
  
        return true
      }
  }
  </code></pre>
  
  <p>But if I make a helper function to handle this, it doesn't work. I need the helper function because this roles check is needed at many places in the app.</p>
  
  <pre><code>  Query: {
      requisitions: async (parent, args, { req }, info) =&gt; {
        hasRights(req, ['driver', 'requestant'])
  
        return true
      }
  }
  
  export const hasRights = async (req, allowedRoles) =&gt; {
      const user = await Auth.findOne({ _id: req.session.userId }).select('roles')
      if (!user.roles.some(role =&gt; allowedRoles.includes(role))) {
        throw new ForbiddenError(ErrorCodes.UNAUTHENTICATED)
      }
  }
  </code></pre>
  
  <p>Note: the hasRights is exported from another file.</p>
  
  <p>I have tried all combinations of try/catch blocks in both files but I just get the UnhandlePromiseRejectionWarning in the server console but the <code>requisitons</code> resolver continues in execution. I want it to stop if the exception is thrown. I have no idea why it only works one way and not the other, even though it is the same thing. Any help appreciated. Thanks.</p>