ModuleRestoreError.js 957 B

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("./Module")} Module */
  8. class ModuleRestoreError 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 restore failed: ";
  15. let details = undefined;
  16. if (err !== null && typeof err === "object") {
  17. if (typeof err.stack === "string" && err.stack) {
  18. const stack = err.stack;
  19. message += stack;
  20. } else if (typeof err.message === "string" && err.message) {
  21. message += err.message;
  22. } else {
  23. message += err;
  24. }
  25. } else {
  26. message += String(err);
  27. }
  28. super(message);
  29. this.name = "ModuleRestoreError";
  30. this.details = details;
  31. this.module = module;
  32. this.error = err;
  33. }
  34. }
  35. module.exports = ModuleRestoreError;