Skip to content

Commit 6a2840f

Browse files
willmendesnetoTheLarkInn
authored andcommitted
refactor(ModuleError): upgrade to ES6 (webpack#3695)
1 parent e968b50 commit 6a2840f

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

lib/ModuleError.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
function ModuleError(module, err) {
6-
Error.call(this);
7-
Error.captureStackTrace(this, ModuleError);
8-
this.name = "ModuleError";
9-
this.module = module;
10-
this.message = err;
11-
this.error = err;
5+
"use strict";
6+
7+
class ModuleError extends Error {
8+
9+
constructor(module, err) {
10+
super();
11+
if(Error.hasOwnProperty("captureStackTrace")) {
12+
Error.captureStackTrace(this, this.constructor);
13+
}
14+
this.name = "ModuleError";
15+
this.module = module;
16+
this.message = err;
17+
this.error = err;
18+
}
1219
}
13-
module.exports = ModuleError;
1420

15-
ModuleError.prototype = Object.create(Error.prototype);
16-
ModuleError.prototype.constructor = ModuleError;
21+
module.exports = ModuleError;

0 commit comments

Comments
 (0)