WebpackError.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Jarid Margolin @jaridmargolin
  4. */
  5. "use strict";
  6. const inspect = require("util").inspect.custom;
  7. const makeSerializable = require("./util/makeSerializable");
  8. /** @typedef {import("./Chunk")} Chunk */
  9. /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
  10. /** @typedef {import("./Module")} Module */
  11. class WebpackError extends Error {
  12. /**
  13. * Creates an instance of WebpackError.
  14. * @param {string=} message error message
  15. */
  16. constructor(message) {
  17. super(message);
  18. this.details = undefined;
  19. /** @type {Module} */
  20. this.module = undefined;
  21. /** @type {DependencyLocation} */
  22. this.loc = undefined;
  23. /** @type {boolean} */
  24. this.hideStack = undefined;
  25. /** @type {Chunk} */
  26. this.chunk = undefined;
  27. /** @type {string} */
  28. this.file = undefined;
  29. }
  30. [inspect]() {
  31. return this.stack + (this.details ? `\n${this.details}` : "");
  32. }
  33. serialize({ write }) {
  34. write(this.name);
  35. write(this.message);
  36. write(this.stack);
  37. write(this.details);
  38. write(this.loc);
  39. write(this.hideStack);
  40. }
  41. deserialize({ read }) {
  42. this.name = read();
  43. this.message = read();
  44. this.stack = read();
  45. this.details = read();
  46. this.loc = read();
  47. this.hideStack = read();
  48. }
  49. }
  50. makeSerializable(WebpackError, "webpack/lib/WebpackError");
  51. module.exports = WebpackError;