Skip to content

Commit 13295cd

Browse files
committed
refactor(es6) upgrade ModuleNotFoundError to ES6 class
1 parent de9323f commit 13295cd

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

lib/ModuleNotFoundError.js

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

19-
ModuleNotFoundError.prototype = Object.create(Error.prototype);
20-
ModuleNotFoundError.prototype.constructor = ModuleNotFoundError;
25+
module.exports = ModuleNotFoundError;

0 commit comments

Comments
 (0)