ModuleStoreError.js 1023 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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("./Module")} Module */
  8. class ModuleStoreError extends WebpackError {
  9. /**
  10. * @param {Module} module module tied to dependency
  11. * @param {string | Error} err error thrown
  12. */
  13. constructor(module, err) {
  14. let message = "Module storing failed: ";
  15. /** @type {string | undefined} */
  16. let details = undefined;
  17. if (err !== null && typeof err === "object") {
  18. if (typeof err.stack === "string" && err.stack) {
  19. const stack = err.stack;
  20. message += stack;
  21. } else if (typeof err.message === "string" && err.message) {
  22. message += err.message;
  23. } else {
  24. message += err;
  25. }
  26. } else {
  27. message += String(err);
  28. }
  29. super(message);
  30. this.name = "ModuleStoreError";
  31. this.details = /** @type {string | undefined} */ (details);
  32. this.module = module;
  33. this.error = err;
  34. }
  35. }
  36. module.exports = ModuleStoreError;