You can override the global error handler within your module:
https://angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html
import { NgModule, ErrorHandler } from '@angular/core';
class MyErrorHandler implements ErrorHandler {
handleError(error) {
// do something with the exception
}
}
@NgModule({
providers: [{ provide: ErrorHandler, useClass: MyErrorHandler }]
})
class MyModule {}
For a custom Error Dialog or Error Message, I would create a custom ErrorLogService, which allows components to subscribe to an error event. The component that shows the error would subscribe to the error event, and display an error message, or popup an error dialog.
See this answer for how to use Flux to do this (the pattern is important - not the specific classes involved):
How can I maintain the state of dialog box with progress all over my Angular 2 application?