UNPKG

1.56 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || function (d, b) {
3 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4 function __() { this.constructor = d; }
5 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6};
7/**
8 * @hidden
9 */
10var Exception = (function (_super) {
11 __extends(Exception, _super);
12 function Exception(message) {
13 _super.call(this, message);
14 this.message = message;
15 this.name = 'Exception';
16 this.stack = (new Error()).stack;
17 }
18 Exception.prototype.toString = function () {
19 return this.name + ": " + this.message;
20 };
21 return Exception;
22}(Error));
23exports.Exception = Exception;
24/**
25 * An error with generic error details.
26 *
27 * Error details can be extracted depending on the type of `D`. For instance,
28 * if the type of `D` is `string[]`, you can do this:
29 *
30 * ```typescript
31 * function handleError(err: IDetailedError<string[]>) {
32 * for (let i in err.details) {
33 * console.error('got error code: ' + i);
34 * }
35 * }
36 * ```
37 *
38 * @featured
39 */
40var DetailedError = (function (_super) {
41 __extends(DetailedError, _super);
42 function DetailedError(
43 /**
44 * The error message.
45 */
46 message,
47 /**
48 * The error details.
49 */
50 details) {
51 _super.call(this, message);
52 this.message = message;
53 this.details = details;
54 this.name = 'DetailedError';
55 }
56 return DetailedError;
57}(Exception));
58exports.DetailedError = DetailedError;