The best solution is to wrap the Http
service with your own service. For example you create a service called YourHttp
. YourHttp
should implement the same interface as Http
.
Inject Http
into YourHttp
and have each method, get
, post
, put
.. etc call the http
method and then catch and handle any errors.
Now in your components inject YourHttp
. For extra credit, configure DI to inject YourHttp
when your components are annotated to have Http
injected.
Update
Now that there is HttpClient, it is best to use an interceptor.