Skip to content

Commit 4d9eb7c

Browse files
authored
Merge pull request webpack#6974 from mohsen1/webpack-error-refactor
Refactor WebpackError to initialize details as undefined
2 parents eca7bad + b6c282f commit 4d9eb7c

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib/WebpackError.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
"use strict";
66

77
module.exports = class WebpackError extends Error {
8+
constructor(message) {
9+
super(message);
10+
11+
this.details = undefined;
12+
13+
Error.captureStackTrace(this, this.constructor);
14+
}
15+
816
inspect() {
917
return this.stack + (this.details ? `\n${this.details}` : "");
1018
}

test/RemovedPlugins.unittest.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ require("should");
44

55
describe("removed plugin errors", () => {
66
it("should error when accessing removed plugins", () => {
7-
(() => webpack.optimize.UglifyJsPlugin).should.throw(
8-
RemovedPluginError,
9-
/webpack\.optimize\.UglifyJsPlugin has been removed, please use config\.optimization\.minimize instead\./
10-
);
7+
(() => webpack.optimize.UglifyJsPlugin).should.throw(RemovedPluginError, {
8+
message: /webpack\.optimize\.UglifyJsPlugin has been removed, please use config\.optimization\.minimize instead\./
9+
});
1110

1211
(() => webpack.optimize.CommonsChunkPlugin).should.throw(
1312
RemovedPluginError,
14-
/webpack\.optimize\.CommonsChunkPlugin has been removed, please use config\.optimization\.splitChunks instead\./
13+
{
14+
message: /webpack\.optimize\.CommonsChunkPlugin has been removed, please use config\.optimization\.splitChunks instead\./
15+
}
1516
);
1617
});
1718
});

0 commit comments

Comments
 (0)