You can create your own HTTPConnection, which processes the error and injects it into the root component of the application at boot time.
export class CustomHTTPConnection implements Connection { }
and then enter it at boot as follows
bootstrap([provider(Connection,{useClass:CustomHTTPConnection}]);
If you want, do not want to provide your own connection class, you can do this for each individual request, since Http returns an observable, which has 3 parameters: onNext, onError, onCompleted.
You can use it as follows:
class Component { constructor(private httpService:HttpService){ } onInit(){ this.httpService.getData().subscribe( ()=>{},
Jigar
source share