title: How to handle an exception 500 error message in Angular
body: <p>I am having difficulties figuring out how to add a custom 500 error message for an exception.</p>
  <p>When the response has the status of Internal Server Error, I receive a backend response that looks like this:</p>
  <pre><code>errors: [
      0: {
        errorCode: null
        exceptionMessage: null
        language: null
        message: &quot;BAPIException with type: E id:  messageNumber: 000 message: Keine Barcodedaten gefunden (ZPORH_BARCODELISTE_CSV)&quot;
        position: null
        reason: null
        subject: null
        subjectType: null,
        type: &quot;BWPErpIntegrationBapiError&quot;
      }
  ]
  </code></pre>
  <p>My internal server handler looks like this so far:</p>
  <pre><code>responseStatus = HttpResponseStatus.INTERNAL_SERVER_ERROR;
  
    // tslint:disable-next-line:variable-name
    handleError(_request: HttpRequest&lt;any&gt;, response: HttpErrorResponse): void {
      if (response.status === this.responseStatus) {
        // console.log(response.error);
        if (response.error?.type === 'BWPErpIntegrationBapiError') {
          this.globalMessageService.add(
            response.error?.message,
            GlobalMessageType.MSG_TYPE_ERROR
          );
        } else {
          // console.log(response.status);
  
          this.globalMessageService.add(
            { key: 'httpHandlers.internalServerError' },
            GlobalMessageType.MSG_TYPE_ERROR
          );
        }
      }
    }
  </code></pre>
  <p>The problem I am facing is that the response I get from the backend is not the same as the <code>HttpErrorResponse</code> from Angular, and I do not know how to approach this problem.
  I tried to extend the HttpErrorResponse and add an <code>errors</code> property that has that array with values and create an interceptor for it but console logging the response.errors[0] was always null.</p>
  <p>Also the way I get this <code>BWPErpIntegrationBapiError</code> exception is by trying to download and CSV that also has a <code>response.error</code> value of <code>Blob</code>.</p>
  <p>Any help would be appreciated!</p>