source: frontend/node_modules/webpack/lib/errors/ModuleError.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: 1.7 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const { cleanUp } = require("../ErrorHelpers");
9const makeSerializable = require("../util/makeSerializable");
10const WebpackError = require("./WebpackError");
11
12/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
13/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
14
15class ModuleError extends WebpackError {
16 /**
17 * @param {Error} err error thrown
18 * @param {{ from?: string | null }} info additional info
19 */
20 constructor(err, { from = null } = {}) {
21 let message = "Module Error";
22
23 message += from ? ` (from ${from}):\n` : ": ";
24
25 if (err && typeof err === "object" && err.message) {
26 message += err.message;
27 } else if (err) {
28 message += err;
29 }
30
31 super(message);
32
33 /** @type {string} */
34 this.name = "ModuleError";
35 /** @type {Error} */
36 this.error = err;
37 /** @type {string | undefined} */
38 this.details =
39 err && typeof err === "object" && err.stack
40 ? cleanUp(err.stack, this.message)
41 : undefined;
42 }
43
44 /**
45 * Serializes this instance into the provided serializer context.
46 * @param {ObjectSerializerContext} context context
47 */
48 serialize(context) {
49 const { write } = context;
50
51 write(this.error);
52
53 super.serialize(context);
54 }
55
56 /**
57 * Restores this instance from the provided deserializer context.
58 * @param {ObjectDeserializerContext} context context
59 */
60 deserialize(context) {
61 const { read } = context;
62
63 this.error = read();
64
65 super.deserialize(context);
66 }
67}
68
69makeSerializable(ModuleError, "webpack/lib/errors/ModuleError");
70
71module.exports = ModuleError;
Note: See TracBrowser for help on using the repository browser.