UNPKG

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