lundi 30 avril 2018

How to properly handle & control Errors in Angular and Web API - 2

I am wondering how to properly handle and control errors in Angular & Web api, on some tutorial I saw that errors are handled in a component and not in a service which is fetching data.. and basically both backend and angular/clients erros are handled in a component like this:

enter image description here

I'm wondering how is possible that he handles both backend and frontend errors in a component? So does that mean I DON'T NEED TRY/CATCH IN A WEB API ? this should handle it also ?

I'm confused here, please explain me this example...

And I thought error handler should be added in a service.ts - in this example PeopleService, while PeopleService looks like this:

enter image description here

So I'm confused about this:

Shouldn't there be logic in a service.ts which would handle errors?

Shouldn't I wrote try/catch in a WebApi, how come backend errors are handled here?

Thanks for help guys Cheers!




Aucun commentaire:

Enregistrer un commentaire