ModuleDependencyError.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. ? /** @type {string} */ (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. /** @type {string} */ (err.stack).split("\n").slice(1).join("\n") +
  30. "\n\n" +
  31. this.stack;
  32. }
  33. }
  34. }
  35. module.exports = ModuleDependencyError;