The Angular documentation on the new HttpClient https://angular.io/guide/http has a section \"Getting error details\" where they show an example like below. I have modified
This might help you
private handleError(err: HttpErrorResponse) {
let errorMessage = '';
if (err.error instanceof Error) {
// A client-side or network error occurred.
errorMessage = `An error occurred: ${err.error.message}`;
} else {
// The backend returned an unsuccessful response code.
// The response body may contain clues as to what went wrong,
errorMessage = `Server returned code: ${err.status}, error message is: ${err.message}`;
}
console.error(errorMessage);
return Observable.throw(errorMessage);
}