errors.js
3.1 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* Convenience to throw an Error with 'unimplemented' as the message.
* @return {?}
*/
export function unimplemented() {
throw new Error('unimplemented');
}
/**
* \@stable
*/
export var BaseError = (function (_super) {
__extends(BaseError, _super);
/**
* @param {?} message
*/
function BaseError(message) {
_super.call(this, message);
// Errors don't use current this, instead they create a new instance.
// We have to do forward all of our api to the nativeInstance.
// TODO(bradfordcsmith): Remove this hack when
// google/closure-compiler/issues/2102 is fixed.
var nativeError = new Error(message);
this._nativeError = nativeError;
}
Object.defineProperty(BaseError.prototype, "message", {
/**
* @return {?}
*/
get: function () { return this._nativeError.message; },
/**
* @param {?} message
* @return {?}
*/
set: function (message) { this._nativeError.message = message; },
enumerable: true,
configurable: true
});
Object.defineProperty(BaseError.prototype, "name", {
/**
* @return {?}
*/
get: function () { return this._nativeError.name; },
enumerable: true,
configurable: true
});
Object.defineProperty(BaseError.prototype, "stack", {
/**
* @return {?}
*/
get: function () { return ((this._nativeError)).stack; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { ((this._nativeError)).stack = value; },
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
BaseError.prototype.toString = function () { return this._nativeError.toString(); };
return BaseError;
}(Error));
function BaseError_tsickle_Closure_declarations() {
/**
* \@internal *
* @type {?}
*/
BaseError.prototype._nativeError;
}
/**
* \@stable
*/
export var WrappedError = (function (_super) {
__extends(WrappedError, _super);
/**
* @param {?} message
* @param {?} error
*/
function WrappedError(message, error) {
_super.call(this, message + " caused by: " + (error instanceof Error ? error.message : error));
this.originalError = error;
}
Object.defineProperty(WrappedError.prototype, "stack", {
/**
* @return {?}
*/
get: function () {
return (((this.originalError instanceof Error ? this.originalError : this._nativeError)))
.stack;
},
enumerable: true,
configurable: true
});
return WrappedError;
}(BaseError));
function WrappedError_tsickle_Closure_declarations() {
/** @type {?} */
WrappedError.prototype.originalError;
}
//# sourceMappingURL=errors.js.map