Skip to content

Commit

Permalink
Merge pull request #418 from ZIMkaRU/bugfix/fix-error-metadata-proces…
Browse files Browse the repository at this point in the history
…sing

Fix error metadata processing
  • Loading branch information
ezewer authored Dec 2, 2024
2 parents ead91b9 + 2776186 commit 9991ca1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions test/1-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('API', () => {
assert.isObject(res.body.error)
assert.propertyVal(res.body.error, 'code', 401)
assert.propertyVal(res.body.error, 'message', 'Unauthorized')
assert.propertyVal(res.body.error, 'data', null)
assert.isObject(res.body.error.data)
assert.propertyVal(res.body, 'id', null)
assert.isString(res.body.jsonrpc)
})
Expand Down Expand Up @@ -1199,10 +1199,11 @@ describe('API', () => {
assert.isObject(res.body)
assert.isObject(res.body.error)
assert.propertyVal(res.body.error, 'code', 400)
assert.isArray(res.body.error.data)
assert.isAbove(res.body.error.data.length, 0)
assert.isObject(res.body.error.data)
assert.isArray(res.body.error.data.errorMetadata)
assert.isAbove(res.body.error.data.errorMetadata.length, 0)

res.body.error.data.forEach((item) => {
res.body.error.data.errorMetadata.forEach((item) => {
assert.isObject(item)
})

Expand Down
14 changes: 8 additions & 6 deletions workers/loc.api/responder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,22 @@ const _getErrorMetadata = (args, err, name) => {
const message = bfxApiErrorMessage
? `${statusMessage}: BFX API Error${bfxApiStatusText}${bfxApiRawBodyResponse}`
: statusMessage
const pubRequestParams = omit(
args?.params ?? null,
[
const pubRequestParams = (
args?.params &&
typeof args?.params === 'object'
)
? omit(args.params, [
'id',
'subAccountApiKeys',
'subAccountPassword',
'addingSubUsers',
'removingSubUsersByEmails'
]
)
])
: args?.params ?? null
const extendedData = {
pubRequestParams,
bfxApiErrorMessage,
...data
errorMetadata: data
}

const error = Object.assign(
Expand Down

0 comments on commit 9991ca1

Please sign in to comment.