angular-errorhandler

Http Error Handling in Angular 6

安稳与你 提交于 2019-12-03 04:16:57
问题 I, am trying to handle the http error using the below class in angular 6. I got a 401 unAuthorized status from server. But however I, don't see the console error message. HttpErrorsHandler.ts file import { ErrorHandler, Injectable} from '@angular/core'; @Injectable() export class HttpErrorsHandler implements ErrorHandler { handleError(error: Error) { // Do whatever you like with the error (send it to the server?) // And log it to the console console.error('It happens: ', error); } } app

Http Error Handling in Angular 6

匆匆过客 提交于 2019-12-02 16:42:24
I, am trying to handle the http error using the below class in angular 6. I got a 401 unAuthorized status from server. But however I, don't see the console error message. HttpErrorsHandler.ts file import { ErrorHandler, Injectable} from '@angular/core'; @Injectable() export class HttpErrorsHandler implements ErrorHandler { handleError(error: Error) { // Do whatever you like with the error (send it to the server?) // And log it to the console console.error('It happens: ', error); } } app.module.ts file providers: [{provide: ErrorHandler, useClass: HttpErrorsHandler}], HttpCallFile import {