Skip to content

Instantly share code, notes, and snippets.

@whisher
Created May 28, 2018 11:27
Show Gist options
  • Save whisher/ae35d6aaa4b32d4e82e8e3d6782a6dda to your computer and use it in GitHub Desktop.
Save whisher/ae35d6aaa4b32d4e82e8e3d6782a6dda to your computer and use it in GitHub Desktop.
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