From ec052417532a10b15ffdd3477b08c1a986a8a301 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 20 Mar 2019 16:57:45 -0700 Subject: [PATCH 1/2] Adds api field to error object with information about the API that triggered an error --- lib/remote.js | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/remote.js b/lib/remote.js index 7977f7b..30bf0f8 100644 --- a/lib/remote.js +++ b/lib/remote.js @@ -97,6 +97,11 @@ module.exports = (cfg, names, params, callback) => { if (response.error && response.error.hasOwnProperty('type')) { error.type = response.error.type; } + error.api = { + name: names.slice(0, 2).join('.'), + function_name: names.slice(3).join('/'), + identifier: !!names[2] ? names[2].replace('@', '') : 'release' + }; return callback(error, response); } else { return callback(null, response, res.headers); diff --git a/package.json b/package.json index d196561..372e439 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lib", - "version": "4.0.2", + "version": "4.0.3", "description": "StdLib: Standard Library for Microservices Node.js Bindings", "main": "lib.js", "engines": { From ec381fe3e0a9cf2d1b08fa5b8d0ad58269a59917 Mon Sep 17 00:00:00 2001 From: Jacob Date: Thu, 21 Mar 2019 10:00:47 -0700 Subject: [PATCH 2/2] Adds API stack trace to error object --- lib/remote.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/remote.js b/lib/remote.js index 138dce1..563dd84 100644 --- a/lib/remote.js +++ b/lib/remote.js @@ -109,6 +109,9 @@ module.exports = (cfg, names, params, callback) => { function_name: names.slice(3).join('/'), identifier: !!names[2] ? names[2].replace('@', '') : 'release' }; + if (response.error && response.error.hasOwnProperty('stack')) { + error.api.stack = response.error.stack; + } return callback(error, response); } else { return callback(null, response, res.headers);