mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
request: add response ID to error objects
This commit is contained in:
parent
4837c2309e
commit
dfff999406
1 changed files with 4 additions and 3 deletions
|
@ -19,7 +19,7 @@ const randomizeUserAgent = (userAgent) => {
|
|||
|
||||
const md5 = input => createHash('md5').update(input).digest()
|
||||
|
||||
const addErrorInfo = (err, errorCode, errorText) => {
|
||||
const addErrorInfo = (err, errorCode, errorText, responseId) => {
|
||||
if (byErrorCode[errorCode]) {
|
||||
Object.assign(err, byErrorCode[errorCode])
|
||||
if (errorCode) err.hafasErrorCode = errorCode
|
||||
|
@ -27,6 +27,7 @@ const addErrorInfo = (err, errorCode, errorText) => {
|
|||
} else {
|
||||
err.code = errorCode || null
|
||||
err.message = errorText || errorCode || null
|
||||
err.responseId = responseId || null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ const request = (ctx, userAgent, reqData) => {
|
|||
if (DEBUG) console.error(JSON.stringify(b))
|
||||
|
||||
if (b.err && b.err !== 'OK') {
|
||||
addErrorInfo(err, b.err, b.errTxt)
|
||||
addErrorInfo(err, b.err, b.errTxt, b.id)
|
||||
throw err
|
||||
}
|
||||
if (!b.svcResL || !b.svcResL[0]) {
|
||||
|
@ -104,7 +105,7 @@ const request = (ctx, userAgent, reqData) => {
|
|||
throw err
|
||||
}
|
||||
if (b.svcResL[0].err !== 'OK') {
|
||||
addErrorInfo(err, b.svcResL[0].err, b.svcResL[0].errTxt)
|
||||
addErrorInfo(err, b.svcResL[0].err, b.svcResL[0].errTxt, b.id)
|
||||
throw err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue