diff --git a/.changes/next-release/bugfix-util-358e56d3.json b/.changes/next-release/bugfix-util-358e56d3.json new file mode 100644 index 0000000000..4ad28ce444 --- /dev/null +++ b/.changes/next-release/bugfix-util-358e56d3.json @@ -0,0 +1,5 @@ +{ + "type": "bugfix", + "category": "util", + "description": "Fix `name.endsWith is not a function` exception when inspecting some generated errors with some versions of nodejs" +} \ No newline at end of file diff --git a/lib/util.js b/lib/util.js index 3234171521..e2f9e6cbeb 100644 --- a/lib/util.js +++ b/lib/util.js @@ -594,7 +594,7 @@ var util = { Object.defineProperty(err, 'message', {enumerable: true}); } - err.name = options && options.name || err.name || err.code || 'Error'; + err.name = String(options && options.name || err.name || err.code || 'Error'); err.time = new Date(); if (originalError) err.originalError = originalError;