There is interface ExceptionHandler through which you can provide custom implementation of your choosing. See here and documentation.
From BETA.0 sources: (facade/exception_handler.d.ts)
/**
* Provides a hook for centralized exception handling.
*
* The default implementation of `ExceptionHandler` prints error messages to the `Console`. To
* intercept error handling,
* write a custom exception handler that replaces this default as appropriate for your app.
*
* ### Example
*
* ```javascript
*
* class MyExceptionHandler implements ExceptionHandler {
* call(error, stackTrace = null, reason = null) {
* // do something with the exception
* }
* }
*
* bootstrap(MyApp, [provide(ExceptionHandler, {useClass: MyExceptionHandler})])
*
* ```
*/
UPDATED:
I had a little problem with BETA.0
- the import had to be hacked,
- the interface seems to be polluted with internal details.
I've run it like:
import {ExceptionHandler} from 'angular2/src/facade/exception_handler';
export interface IExceptionHandler {
call(exception: any, stackTrace?: any, reason?: string): void;
}
export class CustomExceptionHandler implements IExceptionHandler {
call(exception: any, stackTrace: any, reason: string): void {
alert(exception);
}
}
bootstrap(DemoApp, [
new Provider(ExceptionHandler, {
useClass: CustomExceptionHandler
})
]);