source: frontend/node_modules/webpack/lib/errors/WebpackError.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.2 KB
Line 
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/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
15/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
16
17class WebpackError extends Error {
18 /**
19 * Creates an instance of WebpackError.
20 * @param {string=} message error message
21 * @param {{ cause?: unknown }} options error options
22 */
23 constructor(message, options = {}) {
24 super(message, options);
25
26 /** @type {string=} */
27 this.details = undefined;
28 /** @type {(Module | null)=} */
29 this.module = undefined;
30 /** @type {DependencyLocation=} */
31 this.loc = undefined;
32 /** @type {boolean=} */
33 this.hideStack = undefined;
34 /** @type {Chunk=} */
35 this.chunk = undefined;
36 /** @type {string=} */
37 this.file = undefined;
38 }
39
40 /**
41 * Returns inspect message.
42 * @returns {string} inspect message
43 */
44 [inspect]() {
45 return (
46 this.stack +
47 (this.details ? `\n${this.details}` : "") +
48 (this.cause ? `\n${this.cause}` : "")
49 );
50 }
51
52 /**
53 * Serializes this instance into the provided serializer context.
54 * @param {ObjectSerializerContext} context context
55 */
56 serialize({ write }) {
57 write(this.name);
58 write(this.message);
59 write(this.stack);
60 write(this.cause);
61 write(this.details);
62 write(this.loc);
63 write(this.hideStack);
64 }
65
66 /**
67 * Restores this instance from the provided deserializer context.
68 * @param {ObjectDeserializerContext} context context
69 */
70 deserialize({ read }) {
71 this.name = read();
72 this.message = read();
73 this.stack = read();
74 this.cause = read();
75 this.details = read();
76 this.loc = read();
77 this.hideStack = read();
78 }
79}
80
81makeSerializable(WebpackError, "webpack/lib/errors/WebpackError");
82
83/** @type {typeof WebpackError} */
84module.exports = WebpackError;
Note: See TracBrowser for help on using the repository browser.