Warning.js 656 B

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. /**
  3. * **PostCSS Plugin Warning**
  4. *
  5. * Loader wrapper for postcss plugin warnings (`root.messages`)
  6. *
  7. * @class Warning
  8. * @extends Error
  9. *
  10. * @param {Object} warning PostCSS Warning
  11. */
  12. class Warning extends Error {
  13. constructor(warning) {
  14. super(warning);
  15. const {
  16. text,
  17. line,
  18. column,
  19. plugin
  20. } = warning;
  21. this.name = "Warning";
  22. this.message = `${this.name}\n\n`;
  23. if (typeof line !== "undefined") {
  24. this.message += `(${line}:${column}) `;
  25. }
  26. this.message += plugin ? `${plugin}: ` : "";
  27. this.message += `${text}`;
  28. this.stack = false;
  29. }
  30. }
  31. module.exports = Warning;