title: Express runs another block of code after return next()
body: <p>Here is a common function that is used by other middlewares.</p>
  <pre><code>exports.checkIfUserIsAdmin = (user, next) =&gt; {
    if (user.role !== &quot;admin&quot;) {
      return next(
        new catchAppError(
          403,
          &quot;Permission denied. You are not authorized for this resource&quot;
        )
      );
    }
    return true;
  };
  </code></pre>
  <p>Once this is executed, instead of going into the global error block in app.js,it runs console.log() from the middleware.</p>
  <pre><code>exports.addCategories = (Model) =&gt;
    catchAsyncError(async (req, res, next) =&gt; {
      const { name, image } = req.body;
      await this.checkIfUserIsAdmin(req.user, next);
  
      console.log(&quot;===== hi I am running =======&quot;);
  
      let category = await Model.findOne({ name });
  
      sendResponse(200, res, &quot;Category added successfully.&quot;, category);
    }); 
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Rd2N6.jpg" rel="nofollow noreferrer"><strong>Response from the server</strong></a></p>
  <p>Am I missing something??</p>