title: What is the best way to handle custom error cases using AJAX?
body: <p>When returning responses to an AJAX request, I am returning errors such as the following:</p>
  <pre><code>res.status(403).send(&quot;Member not found&quot;);
  </code></pre>
  <p>Say however, I have many similar error cases to return that use the same status code for example:</p>
  <pre><code>res.status(403).send(&quot;Member not verified&quot;);
  </code></pre>
  <p>What would be the best way to handle these cases separately within the error function of my AJAX request?</p>
  <pre><code>$.ajax({
      url: '/portal/change-email',
      data: data,
      dataType: 'json',
      type: 'POST',
      success: function (additionalEmailId) {
        //alert(&quot;Change email ajax success&quot;);
      },
      error: function (xhr, status, error) {
        //Deal with each error here
      }
    });
  </code></pre>