diff --git a/lib/createError.js b/lib/createError.js index aafaac8..be14c3c 100644 --- a/lib/createError.js +++ b/lib/createError.js @@ -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;