UNPKG

1.85 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})();
11/**
12 * @hidden
13 */
14var Exception = (function (_super) {
15 __extends(Exception, _super);
16 function Exception(message) {
17 var _this = _super.call(this, message) || this;
18 _this.message = message;
19 _this.name = 'Exception';
20 _this.stack = new Error().stack;
21 return _this;
22 }
23 Exception.prototype.toString = function () {
24 return this.name + ": " + this.message;
25 };
26 return Exception;
27}(Error));
28export { Exception };
29/**
30 * An error with generic error details.
31 *
32 * Error details can be extracted depending on the type of `D`. For instance,
33 * if the type of `D` is `string[]`, you can do this:
34 *
35 * ```typescript
36 * function handleError(err: IDetailedError<string[]>) {
37 * for (let i in err.details) {
38 * console.error('got error code: ' + i);
39 * }
40 * }
41 * ```
42 *
43 * @featured
44 */
45var DetailedError = (function (_super) {
46 __extends(DetailedError, _super);
47 function DetailedError(
48 /**
49 * The error message.
50 */
51 message,
52 /**
53 * The error details.
54 */
55 details) {
56 var _this = _super.call(this, message) || this;
57 _this.message = message;
58 _this.details = details;
59 _this.name = 'DetailedError';
60 return _this;
61 }
62 return DetailedError;
63}(Exception));
64export { DetailedError };