There is an ExceptionHandler interface through which you can provide a custom implementation of your choice. See here and the 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
- import had to be hacked,
- the interface seems to be dirty with internal details.
I ran it as:
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 }) ]);
wendro Dec 18 '15 at 12:41 2015-12-18 12:41
source share