CssSyntaxError.js 900 B

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