InternalFormatter.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. var __importStar = (this && this.__importStar) || function (mod) {
  6. if (mod && mod.__esModule) return mod;
  7. var result = {};
  8. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  9. result["default"] = mod;
  10. return result;
  11. };
  12. Object.defineProperty(exports, "__esModule", { value: true });
  13. var chalk_1 = __importDefault(require("chalk"));
  14. var os = __importStar(require("os"));
  15. var issue_1 = require("../issue");
  16. /**
  17. * TODO: maybe we should not treat internal errors as issues
  18. */
  19. function createInternalFormatter() {
  20. return function internalFormatter(issue) {
  21. var color = {
  22. message: chalk_1.default.bold.red,
  23. stack: chalk_1.default.grey
  24. };
  25. if (issue.origin === issue_1.IssueOrigin.INTERNAL) {
  26. var lines = [
  27. color.message('INTERNAL ' + issue.severity.toUpperCase()) + ": " + issue.message
  28. ];
  29. if (issue.stack) {
  30. lines.push('stack trace:', color.stack(issue.stack));
  31. }
  32. return lines.join(os.EOL);
  33. }
  34. else {
  35. throw new Error("Not supported \"" + issue.origin + "\" issue origin.");
  36. }
  37. };
  38. }
  39. exports.createInternalFormatter = createInternalFormatter;
  40. //# sourceMappingURL=InternalFormatter.js.map