From 56c252a2a09f1e624fc8630b4ef16989dc10837a Mon Sep 17 00:00:00 2001 From: Michael O'Brien Date: Fri, 18 Aug 2023 14:10:32 +1000 Subject: [PATCH] FIX: case where context is {err} --- .github/workflows/build.yml | 2 +- .vscode/launch.json | 2 +- src/index.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f389d8..ae77e71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [14.x] + node-version: [16.x] steps: - uses: actions/checkout@v2 diff --git a/.vscode/launch.json b/.vscode/launch.json index ae3c0d2..e281d3d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -15,7 +15,7 @@ "args": [ "--runInBand", "--watchAll=false", - "destinations" + "excep" ] } ] diff --git a/src/index.js b/src/index.js index 1464560..ff0b2e9 100644 --- a/src/index.js +++ b/src/index.js @@ -324,13 +324,13 @@ export default class SenseLogs { exception = {code: context.err.code, message: context.err.message, stack: context.err.stack} if (Object.keys(context).length == 1) { // {err} is only context, so hoist - ctx = context.err + ctx = exception } else { delete ctx.err } } if (exception) { - // Error objects are not enumerable by JSON. Convert here and convert stack backtraces to arrays for formatting. + // Error objects are not enumerable by JSON. Convert stack backtraces to arrays for formatting. let err = (ctx['@exception'] = JSON.parse( JSON.stringify(exception, Object.getOwnPropertyNames(exception)), null,