diff --git a/lib/ModuleError.js b/lib/ModuleError.js index 649cc7462..f34ca2727 100644 --- a/lib/ModuleError.js +++ b/lib/ModuleError.js @@ -2,15 +2,20 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -function ModuleError(module, err) { - Error.call(this); - Error.captureStackTrace(this, ModuleError); - this.name = "ModuleError"; - this.module = module; - this.message = err; - this.error = err; -} -module.exports = ModuleError; +"use strict"; -ModuleError.prototype = Object.create(Error.prototype); -ModuleError.prototype.constructor = ModuleError; +class ModuleError extends Error { + + constructor(module, err) { + super(); + if(Error.hasOwnProperty("captureStackTrace")) { + Error.captureStackTrace(this, this.constructor); + } + this.name = "ModuleError"; + this.module = module; + this.message = err; + this.error = err; + } +} + +module.exports = ModuleError;