In this tutorial, We will see how to implement error handling in Angular 4 using Services and Interceptors.
In general, we have a architecture in which there is a component which calls a service which has the
implementation of a method which makes a httprequest to the server.
In case, some thing goes wrong and if there is an error while executing the httprequest then we
can implement the Catch Method in the service method. So the catch method can catch and throw the
error to the component which called it. Now the component can log this error.
But now imagine that your application has 100 of API calls OR httpRequest in the N number of different
service files then you have to implement the catch method in each and every method of those service.
So in order to avoid such repetition of code, we can use interceptors to catch the error at a central
location and directly throwing the error to the component. Without any need to write the error handling
code at the service level.
So we will see Both ways
1. Error Handling at Service level
2. Global Error handling at Interceptor level
#Angular #Angular 8 #Angular7 #Angular 6 #Angular 5
Auf dieser Seite können Sie das Online-Video ANGULAR : Global Error Handling using Interceptors mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Techie Ocean 20 Januar 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 15,475 Mal angesehen und es wurde von 111 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!