UNPKG

957 BJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const WebpackError = require("./WebpackError");
9
10/** @typedef {import("./Module")} Module */
11
12class ModuleRestoreError extends WebpackError {
13 /**
14 * @param {Module} module module tied to dependency
15 * @param {string | Error} err error thrown
16 */
17 constructor(module, err) {
18 let message = "Module restore failed: ";
19 let details = undefined;
20 if (err !== null && typeof err === "object") {
21 if (typeof err.stack === "string" && err.stack) {
22 const stack = err.stack;
23 message += stack;
24 } else if (typeof err.message === "string" && err.message) {
25 message += err.message;
26 } else {
27 message += err;
28 }
29 } else {
30 message += String(err);
31 }
32
33 super(message);
34
35 this.name = "ModuleRestoreError";
36 this.details = details;
37 this.module = module;
38 this.error = err;
39 }
40}
41
42module.exports = ModuleRestoreError;