ModuleRestoreError.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. /** @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 = "ModuleRestoreError";
  31. /** @type {string | undefined} */
  32. this.details = details;
  33. this.module = module;
  34. this.error = err;
  35. }
  36. }
  37. module.exports = ModuleRestoreError;