CssSyntaxError.js 969 B

1234567891011121314151617181920212223242526272829303132333435
  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";
  16. // Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
  17. // We don't need `plugin` and `file` properties.
  18. this.message = `${this.name}\n\n`;
  19. if (typeof line !== "undefined") {
  20. this.message += `(${line}:${column}) `;
  21. }
  22. this.message += file ? `${file} ` : "<css input> ";
  23. this.message += `${reason}`;
  24. const code = error.showSourceCode();
  25. if (code) {
  26. this.message += `\n\n${code}\n`;
  27. }
  28. // We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
  29. this.stack = false;
  30. }
  31. }
  32. exports.default = CssSyntaxError;