2016-01-04 04:42:56 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2017-01-28 10:40:50 +08:00
|
|
|
"use strict";
|
2016-01-04 04:42:56 +08:00
|
|
|
|
2017-03-25 05:17:47 +08:00
|
|
|
const WebpackError = require("./WebpackError");
|
2018-03-22 19:05:58 +08:00
|
|
|
const { cutOffLoaderExecution } = require("./ErrorHelpers");
|
2017-01-28 10:40:50 +08:00
|
|
|
|
2017-03-25 05:17:47 +08:00
|
|
|
class ModuleBuildError extends WebpackError {
|
2017-01-28 10:40:50 +08:00
|
|
|
constructor(module, err) {
|
|
|
|
super();
|
2017-03-25 05:17:47 +08:00
|
|
|
|
2017-01-28 10:40:50 +08:00
|
|
|
this.name = "ModuleBuildError";
|
|
|
|
this.message = "Module build failed: ";
|
2018-02-25 09:00:20 +08:00
|
|
|
if (err !== null && typeof err === "object") {
|
|
|
|
if (typeof err.stack === "string" && err.stack) {
|
2017-03-22 20:00:57 +08:00
|
|
|
var stack = cutOffLoaderExecution(err.stack);
|
2018-02-25 09:00:20 +08:00
|
|
|
if (!err.hideStack) {
|
2017-01-28 10:40:50 +08:00
|
|
|
this.message += stack;
|
2016-01-04 04:42:56 +08:00
|
|
|
} else {
|
2017-01-28 10:40:50 +08:00
|
|
|
this.details = stack;
|
2018-02-25 09:00:20 +08:00
|
|
|
if (typeof err.message === "string" && err.message) {
|
2017-01-28 10:40:50 +08:00
|
|
|
this.message += err.message;
|
|
|
|
} else {
|
|
|
|
this.message += err;
|
|
|
|
}
|
2016-01-04 04:42:56 +08:00
|
|
|
}
|
2018-02-25 09:00:20 +08:00
|
|
|
} else if (typeof err.message === "string" && err.message) {
|
2017-01-28 10:40:50 +08:00
|
|
|
this.message += err.message;
|
|
|
|
} else {
|
|
|
|
this.message += err;
|
2016-01-04 04:42:56 +08:00
|
|
|
}
|
|
|
|
}
|
2017-01-28 10:40:50 +08:00
|
|
|
this.module = module;
|
|
|
|
this.error = err;
|
2017-03-25 05:17:47 +08:00
|
|
|
|
2017-02-16 03:55:54 +08:00
|
|
|
Error.captureStackTrace(this, this.constructor);
|
2016-01-04 04:42:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-28 10:40:50 +08:00
|
|
|
module.exports = ModuleBuildError;
|