UNPKG

2.17 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 if (typeof b !== "function" && b !== null)
11 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12 extendStatics(d, b);
13 function __() { this.constructor = d; }
14 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 };
16})();
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.TSError = exports.INSPECT_CUSTOM = void 0;
19var util_1 = require("util");
20var make_error_1 = require("make-error");
21var logger_1 = require("./logger");
22var messages_1 = require("./messages");
23var logger = logger_1.rootLogger.child({ namespace: 'TSError' });
24/**
25 * @internal
26 */
27exports.INSPECT_CUSTOM = util_1.inspect.custom || 'inspect';
28/**
29 * TypeScript diagnostics error.
30 *
31 * @internal
32 */
33var TSError = /** @class */ (function (_super) {
34 __extends(TSError, _super);
35 function TSError(diagnosticText, diagnosticCodes) {
36 var _this = _super.call(this, (0, messages_1.interpolate)("{{diagnostics}}" /* Errors.UnableToCompileTypeScript */, {
37 diagnostics: diagnosticText.trim(),
38 })) || this;
39 _this.diagnosticText = diagnosticText;
40 _this.diagnosticCodes = diagnosticCodes;
41 _this.name = 'TSError';
42 logger.debug({ diagnosticCodes: diagnosticCodes, diagnosticText: diagnosticText }, 'created new TSError');
43 // ensure we blacklist any of our code
44 Object.defineProperty(_this, 'stack', { value: '' });
45 return _this;
46 }
47 /* istanbul ignore next */
48 TSError.prototype[exports.INSPECT_CUSTOM] = function () {
49 return this.diagnosticText;
50 };
51 return TSError;
52}(make_error_1.BaseError));
53exports.TSError = TSError;