From f6b09ec53061f6c359d516a0f048da22b49a5e11 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Fri, 25 Aug 2017 00:43:31 +0200 Subject: [PATCH] Try to override Constructor#name with Object.defineProperty, if available Attempts to address https://github.com/One-com/node-httperrors/issues/4 --- lib/createError.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;