source: imaps-frontend/node_modules/webpack/lib/ModuleBuildError.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

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