I need your help to recommend me documents or links that solve my question. Actually in Angular 4, I want to customize error from api services. For example, if the server responses the request with error, the error will be shown to user. My question is how can I get all errors from server and for each ones write codes for user in front-end. Thank you in advance.
1 Answer
You can make HTTP interceptor and collect all server error in single service and modify them according to your requirement.
This is one of the simplest implementation I have found https://hackernoon.com/global-http-request-error-catching-in-angular-486a319f59ab
@ExceptionHandler) and in your front end You can try to use.catch((err: any) => { if(err.status == 'your code e.g 84573'){ console.error('An special error occurred coneccted to the business logic:', err.error); } });This(more or less this) was working in angularjs - probably will work here too but i'm not 100% sure.