Created
May 28, 2018 11:27
-
-
Save whisher/ae35d6aaa4b32d4e82e8e3d6782a6dda to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class HttpErrorHandler { | |
| static handleError(error: HttpErrorResponse) { | |
| let errorMessage = ''; | |
| if (error.error instanceof ErrorEvent) { | |
| errorMessage = error.error.message; | |
| } else { | |
| const errorMessage = `Server returned code: ${error.status}, error message is: ${error.error}`; | |
| } | |
| const msg = environment.production ? 'Something bad happened; please try again later.' : errorMessage; | |
| return throwError(msg); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment