Skip to content

Commit

Permalink
Merge pull request #360 from ZIMkaRU/feature/extend-error-logs-for-sy…
Browse files Browse the repository at this point in the history
…nc-proc

Extend error logs for sync proc
  • Loading branch information
ezewer authored Mar 29, 2024
2 parents 18b5ece + adf35fa commit 8dd0975
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions workers/loc.api/responder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const _getErrorWithMetadataForNonBaseError = (args, err) => {
return err
}

const _getErrorMetadata = (args, err) => {
const _getErrorMetadata = (args, err, name) => {
const errWithMetadata = _getErrorWithMetadataForNonBaseError(args, err)
_addStatusMessageToErrorMessage(errWithMetadata)
const {
Expand Down Expand Up @@ -178,8 +178,10 @@ const _getErrorMetadata = (args, err) => {
data: extendedData
}
)
const serializedError = _prepareErrorData(error, name)
Object.assign(error, { serializedError })

return { code, message, data, error }
return { code, message, data, error, serializedError }
}

const _logError = (loggerArgs, err) => {
Expand All @@ -195,21 +197,22 @@ const _logError = (loggerArgs, err) => {
)
const {
code,
error
} = _getErrorMetadata(args, err)
error,
serializedError
} = _getErrorMetadata(args, err, name)

_emitEventByWs(loggerArgs, error)

if (
code !== 500 ||
shouldNotBeLoggedToStdErrorStream
) {
logger.debug(_prepareErrorData(error, name))
logger.debug(serializedError)

return
}

logger.error(_prepareErrorData(error, name))
logger.error(serializedError)
}

const _emitEventByWs = (emitterArgs, error) => {
Expand Down

0 comments on commit 8dd0975

Please sign in to comment.