ModuleDependencyError.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const WebpackError = require("./WebpackError");
  7. /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
  8. /** @typedef {import("./Module")} Module */
  9. class ModuleDependencyError extends WebpackError {
  10. /**
  11. * Creates an instance of ModuleDependencyError.
  12. * @param {Module} module module tied to dependency
  13. * @param {Error} err error thrown
  14. * @param {DependencyLocation} loc location of dependency
  15. */
  16. constructor(module, err, loc) {
  17. super(err.message);
  18. this.name = "ModuleDependencyError";
  19. this.details =
  20. err && !(/** @type {any} */ (err).hideStack)
  21. ? err.stack.split("\n").slice(1).join("\n")
  22. : undefined;
  23. this.module = module;
  24. this.loc = loc;
  25. /** error is not (de)serialized, so it might be undefined after deserialization */
  26. this.error = err;
  27. if (err && /** @type {any} */ (err).hideStack) {
  28. this.stack =
  29. err.stack.split("\n").slice(1).join("\n") + "\n\n" + this.stack;
  30. }
  31. }
  32. }
  33. module.exports = ModuleDependencyError;