CssSyntaxError.js 968 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. class CssSyntaxError extends Error {
  7. constructor(error) {
  8. super(error);
  9. const {
  10. reason,
  11. line,
  12. column,
  13. file
  14. } = error;
  15. this.name = "CssSyntaxError"; // Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
  16. // We don't need `plugin` and `file` properties.
  17. this.message = `${this.name}\n\n`;
  18. if (typeof line !== "undefined") {
  19. this.message += `(${line}:${column}) `;
  20. }
  21. this.message += file ? `${file} ` : "<css input> ";
  22. this.message += `${reason}`;
  23. const code = error.showSourceCode();
  24. if (code) {
  25. this.message += `\n\n${code}\n`;
  26. } // We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
  27. this.stack = false;
  28. }
  29. }
  30. exports.default = CssSyntaxError;