Skip to content

Commit

Permalink
Try to override Constructor#name with Object.defineProperty, if avail…
Browse files Browse the repository at this point in the history
…able

Attempts to address One-com/node-httperrors#4
  • Loading branch information
papandreou committed Aug 24, 2017
1 parent 65b1ea3 commit f6b09ec
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/createError.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@
inherits(Constructor, SuperConstructor || Error);

if (options.name) {
Constructor.name = options.name;
if (Object.defineProperty) {
Object.defineProperty(Constructor, 'name', { value: options.name });
} else {
Constructor.name = options.name;
}
}

return Constructor;
Expand Down

0 comments on commit f6b09ec

Please sign in to comment.