SassError.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. class SassError extends Error {
  7. constructor(sassError) {
  8. super();
  9. this.name = "SassError"; // TODO remove me in the next major release
  10. this.originalSassError = sassError;
  11. if (typeof sassError.line !== "undefined" || typeof sassError.column !== "undefined") {
  12. this.loc = {
  13. line: sassError.line,
  14. column: sassError.column
  15. };
  16. } // Keep original error if `sassError.formatted` is unavailable
  17. this.message = `${this.name}: ${typeof this.originalSassError.message !== "undefined" ? this.originalSassError.message : this.originalSassError}`;
  18. if (this.originalSassError.formatted) {
  19. this.message = `${this.name}: ${this.originalSassError.formatted.replace(/^Error: /, "")}`; // Instruct webpack to hide the JS stack from the console.
  20. // Usually you're only interested in the SASS stack in this case.
  21. this.hideStack = true;
  22. Error.captureStackTrace(this, this.constructor);
  23. }
  24. }
  25. }
  26. var _default = SassError;
  27. exports.default = _default;