Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ModuleBuildError.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. const { cutOffLoaderExecution } = require("./ErrorHelpers");
  8. class ModuleBuildError extends WebpackError {
  9. constructor(module, err, { from = null } = {}) {
  10. let message = "Module build failed";
  11. let details = undefined;
  12. if (from) {
  13. message += ` (from ${from}):\n`;
  14. } else {
  15. message += ": ";
  16. }
  17. if (err !== null && typeof err === "object") {
  18. if (typeof err.stack === "string" && err.stack) {
  19. const stack = cutOffLoaderExecution(err.stack);
  20. if (!err.hideStack) {
  21. message += stack;
  22. } else {
  23. details = stack;
  24. if (typeof err.message === "string" && err.message) {
  25. message += err.message;
  26. } else {
  27. message += err;
  28. }
  29. }
  30. } else if (typeof err.message === "string" && err.message) {
  31. message += err.message;
  32. } else {
  33. message += err;
  34. }
  35. } else {
  36. message = err;
  37. }
  38. super(message);
  39. this.name = "ModuleBuildError";
  40. this.details = details;
  41. this.module = module;
  42. this.error = err;
  43. Error.captureStackTrace(this, this.constructor);
  44. }
  45. }
  46. module.exports = ModuleBuildError;