source: trip-planner-front/node_modules/webpack/lib/ModuleError.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 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 WebpackError = require("./WebpackError");
10const makeSerializable = require("./util/makeSerializable");
11
12class ModuleError extends WebpackError {
13 /**
14 * @param {Error} err error thrown
15 * @param {{from?: string|null}} info additional info
16 */
17 constructor(err, { from = null } = {}) {
18 let message = "Module Error";
19
20 if (from) {
21 message += ` (from ${from}):\n`;
22 } else {
23 message += ": ";
24 }
25
26 if (err && typeof err === "object" && err.message) {
27 message += err.message;
28 } else if (err) {
29 message += err;
30 }
31
32 super(message);
33
34 this.name = "ModuleError";
35 this.error = err;
36 this.details =
37 err && typeof err === "object" && err.stack
38 ? cleanUp(err.stack, this.message)
39 : undefined;
40 }
41
42 serialize(context) {
43 const { write } = context;
44
45 write(this.error);
46
47 super.serialize(context);
48 }
49
50 deserialize(context) {
51 const { read } = context;
52
53 this.error = read();
54
55 super.deserialize(context);
56 }
57}
58
59makeSerializable(ModuleError, "webpack/lib/ModuleError");
60
61module.exports = ModuleError;
Note: See TracBrowser for help on using the repository browser.