ts-error.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. var __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 (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var make_error_1 = require("make-error");
  17. var util_1 = require("util");
  18. var logger_1 = require("./logger");
  19. var messages_1 = require("./messages");
  20. var logger = logger_1.rootLogger.child({ namespace: 'TSError' });
  21. exports.INSPECT_CUSTOM = util_1.inspect.custom || 'inspect';
  22. var TSError = (function (_super) {
  23. __extends(TSError, _super);
  24. function TSError(diagnosticText, diagnosticCodes) {
  25. var _this = _super.call(this, messages_1.interpolate(messages_1.Errors.UnableToCompileTypeScript, {
  26. diagnostics: diagnosticText.trim(),
  27. help: messages_1.Helps.IgnoreDiagnosticCode,
  28. })) || this;
  29. _this.diagnosticText = diagnosticText;
  30. _this.diagnosticCodes = diagnosticCodes;
  31. _this.name = 'TSError';
  32. logger.debug({ diagnosticCodes: diagnosticCodes, diagnosticText: diagnosticText }, 'created new TSError');
  33. Object.defineProperty(_this, 'stack', { value: '' });
  34. return _this;
  35. }
  36. TSError.prototype[exports.INSPECT_CUSTOM] = function () {
  37. return this.diagnosticText;
  38. };
  39. return TSError;
  40. }(make_error_1.BaseError));
  41. exports.TSError = TSError;