source: trip-planner-front/node_modules/webpack/lib/ModuleBuildError.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.6 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 { cutOffLoaderExecution } = require("./ErrorHelpers");
9const WebpackError = require("./WebpackError");
10const makeSerializable = require("./util/makeSerializable");
11
12class ModuleBuildError extends WebpackError {
13 /**
14 * @param {string | Error&any} err error thrown
15 * @param {{from?: string|null}} info additional info
16 */
17 constructor(err, { from = null } = {}) {
18 let message = "Module build failed";
19 let details = undefined;
20
21 if (from) {
22 message += ` (from ${from}):\n`;
23 } else {
24 message += ": ";
25 }
26
27 if (err !== null && typeof err === "object") {
28 if (typeof err.stack === "string" && err.stack) {
29 const stack = cutOffLoaderExecution(err.stack);
30
31 if (!err.hideStack) {
32 message += stack;
33 } else {
34 details = stack;
35
36 if (typeof err.message === "string" && err.message) {
37 message += err.message;
38 } else {
39 message += err;
40 }
41 }
42 } else if (typeof err.message === "string" && err.message) {
43 message += err.message;
44 } else {
45 message += String(err);
46 }
47 } else {
48 message += String(err);
49 }
50
51 super(message);
52
53 this.name = "ModuleBuildError";
54 this.details = details;
55 this.error = err;
56 }
57
58 serialize(context) {
59 const { write } = context;
60
61 write(this.error);
62
63 super.serialize(context);
64 }
65
66 deserialize(context) {
67 const { read } = context;
68
69 this.error = read();
70
71 super.deserialize(context);
72 }
73}
74
75makeSerializable(ModuleBuildError, "webpack/lib/ModuleBuildError");
76
77module.exports = ModuleBuildError;
Note: See TracBrowser for help on using the repository browser.