refactor(ModuleError): upgrade to ES6 (#3695)

This commit is contained in:
Will Mendes 2017-01-04 05:27:43 +11:00 committed by Sean Larkin
parent e968b5059b
commit 6a2840f104
1 changed files with 16 additions and 11 deletions

View File

@ -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;