Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## @global-owner1 and @global-owner2 will be requested for
## review when someone opens a pull request.
#* @global-owner1 @global-owner2
* @elnyry-sam-k @bushjames @shashi165 @gibaros
* @elnyry-sam-k @bushjames @shashi165 @gibaros @vijayg10 @kleyow @geka-evk @oderayi @kalinkrustev

## Order is important; the last matching pattern takes the most
## precedence. When someone opens a pull request that only
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@mojaloop/central-services-error-handling",
"version": "13.1.0",
"version": "13.1.1-snapshot.0",
"description": "Hapi error handling module",
"main": "src/index.js",
"pre-commit": [
"lint",
"test",
"dep:check",
"test"
"audit:check"
],
"scripts": {
"test": "npm run test:unit",
Expand Down Expand Up @@ -54,12 +55,12 @@
"devDependencies": {
"@hapi/boom": "10.0.1",
"audit-ci": "^7.1.0",
"npm-check-updates": "18.0.1",
"npm-check-updates": "18.1.0",
"nyc": "17.1.0",
"pre-commit": "1.2.2",
"proxyquire": "2.1.3",
"replace": "^1.2.2",
"sinon": "20.0.0",
"sinon": "21.0.0",
"standard": "17.1.2",
"standard-version": "^9.5.0",
"tap-spec": "^5.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ const MojaloopApiErrorCodes = {
MISSING_MANDATORY_EXTENSION: { code: '3107', message: 'Missing mandatory extension parameter', httpStatusCode: 400 },

// identifier errors
ID_NOT_FOUND: { code: '3200', message: 'Generic ID not found' },
ID_NOT_FOUND: { code: '3200', message: 'Generic ID not found', httpStatusCode: 400 },
DESTINATION_FSP_ERROR: { code: '3201', message: 'Destination FSP Error' },
PAYER_FSP_ID_NOT_FOUND: { code: '3202', message: 'Payer FSP ID not found' },
PAYEE_FSP_ID_NOT_FOUND: { code: '3203', message: 'Payee FSP ID not found' },
PARTY_NOT_FOUND: { code: '3204', message: 'Party not found' },
PARTY_NOT_FOUND: { code: '3204', message: 'Party not found', httpStatusCode: 400 },
QUOTE_ID_NOT_FOUND: { code: '3205', message: 'Quote ID not found' },
TXN_REQUEST_ID_NOT_FOUND: { code: '3206', message: 'Transaction request ID not found' },
TXN_ID_NOT_FOUND: { code: '3207', message: 'Transaction ID not found' },
Expand Down
17 changes: 9 additions & 8 deletions src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@

'use strict'

const Enums = require('./enums')
const _ = require('lodash')
const stringify = require('fast-safe-stringify')
const Enums = require('./enums')
const { MojaloopFSPIOPError } = require('./errors')

/**
Expand Down Expand Up @@ -81,7 +82,7 @@ class FSPIOPError extends MojaloopFSPIOPError {
} else if (this.cause instanceof Error) {
stringifiedCause = this.cause.stack
} else {
stringifiedCause = JSON.stringify(this.cause)
stringifiedCause = stringify(this.cause)
}
if (stringifiedCause) this.stack = `${this.stack}\n${stringifiedCause}`
}
Expand Down Expand Up @@ -165,7 +166,7 @@ class FSPIOPError extends MojaloopFSPIOPError {
}

toString () {
return JSON.stringify(this.toFullErrorObject())
return stringify(this.toFullErrorObject())
}
}

Expand All @@ -187,7 +188,7 @@ const createFSPIOPError = (apiErrorCode, message, cause, replyTo, extensions, us
if (!match) {
match = Enums.findErrorType(apiErrorCode.code)
if (!match) {
throw new FSPIOPError(cause, `Factory function createFSPIOPError failed due to apiErrorCode being invalid - ${JSON.stringify(apiErrorCode)}.`, replyTo, Enums.FSPIOPErrorCodes.INTERNAL_SERVER_ERROR, extensions)
throw new FSPIOPError(cause, `Factory function createFSPIOPError failed due to apiErrorCode being invalid - ${stringify(apiErrorCode)}.`, replyTo, Enums.FSPIOPErrorCodes.INTERNAL_SERVER_ERROR, extensions)
}
if (!newApiError.httpStatusCode) {
newApiError.httpStatusCode = match.httpStatusCode
Expand All @@ -197,7 +198,7 @@ const createFSPIOPError = (apiErrorCode, message, cause, replyTo, extensions, us
}
return new FSPIOPError(cause, message, replyTo, newApiError, extensions, useDescriptionAsMessage)
} else {
throw new FSPIOPError(cause, `Factory function createFSPIOPError failed due to apiErrorCode being invalid - ${JSON.stringify(apiErrorCode)}.`, replyTo, Enums.FSPIOPErrorCodes.INTERNAL_SERVER_ERROR, extensions)
throw new FSPIOPError(cause, `Factory function createFSPIOPError failed due to apiErrorCode being invalid - ${stringify(apiErrorCode)}.`, replyTo, Enums.FSPIOPErrorCodes.INTERNAL_SERVER_ERROR, extensions)
}
}

Expand Down Expand Up @@ -295,7 +296,7 @@ const createFSPIOPErrorFromOpenapiError = (error, replyTo) => {
} else if (error.dataPath) { // replaced by instancePath, ref: https://github.com/ajv-validator/ajv/releases/tag/v8.0.0. This branch is kept here for backward compatibility.
message = error.dataPath
} else {
message = JSON.stringify(error)
message = stringify(error)
}
}
return createFSPIOPError(fspiopError, message, replyTo)
Expand Down Expand Up @@ -386,7 +387,7 @@ const validateFSPIOPErrorCode = (code) => {
if (result) {
return result
} else {
throw createInternalServerFSPIOPError(`${errorMessage} - ${JSON.stringify(code)}.`)
throw createInternalServerFSPIOPError(`${errorMessage} - ${stringify(code)}.`)
}
}

Expand All @@ -411,7 +412,7 @@ const validateFSPIOPErrorGroups = (code) => {
if (regex.test(codeToValidate)) {
return true
} else {
throw createInternalServerFSPIOPError(`${errorMessage} - ${JSON.stringify(code)}.`)
throw createInternalServerFSPIOPError(`${errorMessage} - ${stringify(code)}.`)
}
}

Expand Down