July 2018
Intermediate to advanced
420 pages
8h 46m
English
You should have noticed that the login() and register() functions have a catchError function that points to another function called the handleError. At this moment in time, we are going to create this function, which is in charge of showing the possible errors that our request may have.
Add the following code right after the getUser() function:
private handleError(error: HttpErrorResponse) {
if (error.error instanceof ErrorEvent) {
// A client-side error.
console.error('An error occurred:', error.error.message);
} else {
// The backend error.
return throwError(error);
}
// return a custom error message
return throwError('Ohps something wrong happen here; please try again later.');
}
We are logging the error ...
Read now
Unlock full access