-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathErrorHandler.js
62 lines (62 loc) · 2.64 KB
/
ErrorHandler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
define(["require", "exports", 'dojo/aspect', './has', 'dojo/_base/lang', './Observable', './util', "./templating/html!./views/Error.html"], function (require, exports, aspect, has, lang, Observable, util) {
var ErrorHandler = (function (_super) {
__extends(ErrorHandler, _super);
function ErrorHandler() {
_super.apply(this, arguments);
}
ErrorHandler.prototype._initialize = function () {
_super.prototype._initialize.call(this);
this._handleGlobalErrors = true;
};
ErrorHandler.prototype.destroy = function () {
this._handle && this._handle.remove();
this._handle = null;
_super.prototype.destroy.call(this);
};
ErrorHandler.prototype.handleError = function (error) {
if (has('host-browser') && this._app.get('ui')) {
var ErrorView = require('./templating/html!./views/Error.html');
var view = new ErrorView({
app: this._app,
model: error
});
this._app.get('ui').set('view', view);
}
else {
this._app.log(error.stack || String(error));
}
};
ErrorHandler.prototype.run = function () {
this.run = function () {
};
var self = this;
if (this._handleGlobalErrors) {
if (has('host-browser')) {
this._handle = aspect.before(window, 'onerror', function (message, url, lineNumber, columnNumber, error) {
if (!error) {
error = new Error(message);
error.stack = 'Error: ' + message + '\n at window.onerror (' + url + ':' + lineNumber + ':' + (columnNumber || 0) + ')';
}
self.handleError(error);
});
}
else if (has('host-node')) {
var listener = lang.hitch(this, 'handleError');
process.on('uncaughtException', listener);
this._handle = util.createHandle(function () {
process.removeListener('uncaughtException', listener);
});
}
}
};
return ErrorHandler;
})(Observable);
return ErrorHandler;
});
//# sourceMappingURL=_debug/ErrorHandler.js.map