Error.js 815 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. /**
  3. * **PostCSS Syntax Error**
  4. *
  5. * Loader wrapper for postcss syntax errors
  6. *
  7. * @class SyntaxError
  8. * @extends Error
  9. *
  10. * @param {Object} err CssSyntaxError
  11. */
  12. class SyntaxError extends Error {
  13. constructor(error) {
  14. super(error);
  15. const {
  16. line,
  17. column,
  18. reason,
  19. plugin,
  20. file
  21. } = error;
  22. this.name = "SyntaxError";
  23. this.message = `${this.name}\n\n`;
  24. if (typeof line !== "undefined") {
  25. this.message += `(${line}:${column}) `;
  26. }
  27. this.message += plugin ? `${plugin}: ` : "";
  28. this.message += file ? `${file} ` : "<css input> ";
  29. this.message += `${reason}`;
  30. const code = error.showSourceCode();
  31. if (code) {
  32. this.message += `\n\n${code}\n`;
  33. }
  34. this.stack = false;
  35. }
  36. }
  37. module.exports = SyntaxError;