UNPKG

2.41 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = Object.setPrototypeOf ||
3 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5 return function (d, b) {
6 extendStatics(d, b);
7 function __() { this.constructor = d; }
8 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9 };
10})();
11import { ErrorHandler } from '@angular/core';
12/**
13 * @name IonicErrorHandler
14 * @description
15 * The `IonicErrorHandler` intercepts the default `Console` error handling
16 * and displays runtime errors as an overlay when using Ionic's Dev Build Server.
17 *
18 *
19 * ### IonicErrorHandler Example
20 *
21 * ```typescript
22 * import { ErrorHandler, NgModule } from '@angular/core';
23 * import { IonicErrorHandler } from 'ionic-angular';
24 *
25 * @NgModule({
26 * providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }]
27 * })
28 * class AppModule { }
29 * ```
30 *
31 *
32 * ### Custom Error Handlers
33 *
34 * Custom error handlers can be built to replace the default, or extend Ionic's
35 * error handler.
36 *
37 * ```typescript
38 * class MyErrorHandler implements ErrorHandler {
39 * handleError(err: any): void {
40 * // do something with the error
41 * }
42 * }
43 *
44 * @NgModule({
45 * providers: [{ provide: ErrorHandler, useClass: MyErrorHandler }]
46 * })
47 * class AppModule { }
48 * ```
49 *
50 * More information about Angular's [`ErrorHandler`](https://angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html).
51 */
52var IonicErrorHandler = (function (_super) {
53 __extends(IonicErrorHandler, _super);
54 function IonicErrorHandler() {
55 return _super.call(this) || this;
56 }
57 /**
58 * @internal
59 */
60 IonicErrorHandler.prototype.handleError = function (err) {
61 _super.prototype.handleError.call(this, err);
62 try {
63 var win = window;
64 var monitor = void 0;
65 monitor = win['IonicDevServer'];
66 monitor && monitor.handleError && monitor.handleError(err);
67 monitor = (win['Ionic'] = win['Ionic'] || {}).Monitor;
68 monitor && monitor.handleError && monitor.handleError(err);
69 }
70 catch (e) { }
71 };
72 return IonicErrorHandler;
73}(ErrorHandler));
74export { IonicErrorHandler };
75//# sourceMappingURL=ionic-error-handler.js.map
\No newline at end of file