2016-01-04 04:42:56 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2017-01-04 02:27:43 +08:00
|
|
|
"use strict";
|
|
|
|
|
2017-03-25 05:17:47 +08:00
|
|
|
const WebpackError = require("./WebpackError");
|
2018-03-22 19:05:58 +08:00
|
|
|
const { cleanUp } = require("./ErrorHelpers");
|
2017-03-22 20:00:57 +08:00
|
|
|
|
2017-03-25 05:17:47 +08:00
|
|
|
class ModuleError extends WebpackError {
|
2017-01-04 02:27:43 +08:00
|
|
|
constructor(module, err) {
|
|
|
|
super();
|
2017-02-16 03:55:54 +08:00
|
|
|
|
2017-01-04 02:27:43 +08:00
|
|
|
this.name = "ModuleError";
|
|
|
|
this.module = module;
|
2018-02-25 09:00:20 +08:00
|
|
|
this.message =
|
|
|
|
err && typeof err === "object" && err.message ? err.message : err;
|
2017-01-04 02:27:43 +08:00
|
|
|
this.error = err;
|
2018-02-25 09:00:20 +08:00
|
|
|
this.details =
|
|
|
|
err && typeof err === "object" && err.stack
|
|
|
|
? cleanUp(err.stack, this.message)
|
|
|
|
: undefined;
|
2017-02-16 03:55:54 +08:00
|
|
|
|
|
|
|
Error.captureStackTrace(this, this.constructor);
|
2017-01-04 02:27:43 +08:00
|
|
|
}
|
2016-01-04 04:42:56 +08:00
|
|
|
}
|
|
|
|
|
2017-01-04 02:27:43 +08:00
|
|
|
module.exports = ModuleError;
|