ANGULAR : Global Error Handling using Interceptors

Pubblicato il: 20 gennaio 2018
sul canale di: Techie Ocean
15,475
111

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


In questa pagina del sito puoi guardare il video online ANGULAR : Global Error Handling using Interceptors della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Techie Ocean 20 gennaio 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 15,475 volte e gli è piaciuto 111 spettatori. Buona visione!