Skip to content

Commit bc4196c

Browse files
authored
Merge pull request webpack#4029 from carloscuatin/refactor-module-not-found-error
refactor(es6) upgrade ModuleNotFoundError to ES6 class
2 parents 3ee35f6 + 49579d6 commit bc4196c

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

lib/ModuleNotFoundError.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
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+
super();
10+
if(Error.hasOwnProperty("captureStackTrace")) {
11+
Error.captureStackTrace(this, this.constructor);
12+
}
13+
this.name = "ModuleNotFoundError";
14+
this.message = "Module not found: " + err;
15+
this.details = err.details;
16+
this.missing = err.missing;
17+
this.module = module;
18+
this.origin = module;
19+
this.dependencies = dependencies;
20+
this.error = err;
21+
}
1622
}
17-
module.exports = ModuleNotFoundError;
1823

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

0 commit comments

Comments
 (0)