UNPKG

1.43 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 Error.captureStackTrace(this, this.constructor);
36 }
37
38 [inspect]() {
39 return this.stack + (this.details ? `\n${this.details}` : "");
40 }
41
42 serialize({ write }) {
43 write(this.name);
44 write(this.message);
45 write(this.stack);
46 write(this.details);
47 write(this.loc);
48 write(this.hideStack);
49 }
50
51 deserialize({ read }) {
52 this.name = read();
53 this.message = read();
54 this.stack = read();
55 this.details = read();
56 this.loc = read();
57 this.hideStack = read();
58 }
59}
60
61makeSerializable(WebpackError, "webpack/lib/WebpackError");
62
63module.exports = WebpackError;