title: extracting the error status/message from POST call in angular
body: <p>I have a POST call to rest api from my angular service, and I want to return either the error status or the error message to do some logic on it, but am always getting [Object] as response (or undefined, depends on what I return from my error handling method) and I'm not managing to parse it!</p>
  
  <p>From my service:</p>
  
  <pre><code>addDbResource(resource) {
     //console.log(JSON.stringify(resource));
  
      this.http.post(this.url + "resource", JSON.stringify(resource), this.options)
          //.map(this.extractData)
          .map(res =&gt; this.errorStatus = res)
          .catch(this.handleObservableError)
          .subscribe();
  
     return this.errorStatus;
  }  
  
  
  private handleObservableError (error: Response | any) {
      //console.error("Error1: " + error.message || error);
      let errMsg = (error.message) ? error.message :
          error.status ? error.status + " - " + error.statusText : 'Server error';
  
      document.getElementById("alert").innerHTML = error.json().message;
  
      return Observable.throw(error.status);
      //return Observable.throw(error.message || error);
      //return error.status;
  }
  </code></pre>
  
  <p>PSB a <a href="https://i.stack.imgur.com/gh86d.png" rel="nofollow noreferrer">screenshot</a></p>