From 29b25d3b773f8dc83d897d28fa9314ce70b28e0d Mon Sep 17 00:00:00 2001 From: Pavel Rogovoi <51755949+pajgo@users.noreply.github.com> Date: Thu, 3 Feb 2022 19:04:26 +0600 Subject: [PATCH] feat: add `errorCode` and map `detail` to `err.detail` --- src/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 6132de4..8b16b02 100644 --- a/src/index.js +++ b/src/index.js @@ -75,15 +75,18 @@ module.exports = { response.errors.push({ status: body.name, code: res.statusCode, + // extract error internal code + errorCode: body.code, title: titleToReadable(body.name, title), - detail: err.errors, + detail: err.errors || err.detail, }); } else { response.errors.push({ status: body.name || 'InternalServerError', code: res.statusCode, + errorCode: body.code, title: titleToReadable(body.name, body.toString()), - detail: body.reason || body.errors || {}, + detail: body.reason || body.errors || body.detail || {}, stack: (isProd !== true && (is.string(body.stack) ? body.stack.split('\n') : body.stack)) || undefined, }); }