Last active
March 27, 2018 15:48
-
-
Save dlueth/f4a49c7caa974de4e3a29f1e9cae7bec to your computer and use it in GitHub Desktop.
Revisions
-
dlueth revised this gist
Mar 27, 2018 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,15 @@ class CustomError extends Error { super(...args); Object.defineProperty(this, 'name', { value: this.constructor.name }); // This is for Node only... Error.captureStackTrace(this, this.constructor); // ... whereas use this for Browser instead /* if(Error.captureStackTrace) { Error.captureStackTrace(this, CustomError); } */ } } -
dlueth revised this gist
Jan 2, 2018 . No changes.There are no files selected for viewing
-
dlueth revised this gist
Jan 2, 2018 . No changes.There are no files selected for viewing
-
dlueth created this gist
Jul 25, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ 'use strict'; class CustomError extends Error { constructor(...args) { super(...args); Object.defineProperty(this, 'name', { value: this.constructor.name }); Error.captureStackTrace(this, this.constructor); } } class ExtendedError extends CustomError { constructor(...args) { super(...args); } } try { throw new ExtendedError('gnarf') } catch(err) { console.log(err.name); console.log(err); } module.exports = CustomError;