Skip to content

Instantly share code, notes, and snippets.

View envynoiz's full-sized avatar

Jorge Palomo envynoiz

View GitHub Profile
@envynoiz
envynoiz / ecm6_exception.js
Last active June 11, 2018 02:16
Creating a custom exception using ECMAScript 6
class CustomException extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
if ('function' === typeof Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = (new Error(message)).stack;
}
}