Return right OCPI Http codes
MODIFY
src/server/ocpi/service/common/v2.1.1/CPOEMSPCredentialsService.ts
src/server/ocpi/service/common/v2.1.1/CPOEMSPCredentialsService.ts
@@ -109,8 +109,9 @@ export default class CPOEMSPCredentialsService {
detailedMessages: { versions: response.data }
});
// Check response
- if (!response.data || !response.data.data) {
- throw new BackendError({
+ if (!response.data?.data) {
+ throw new AppError({
+ errorCode: StatusCodes.NOT_FOUND,
module: MODULE_NAME, method: 'handleUpdateCreateCredentials', action,
message: `Invalid response from GET ${ocpiEndpoint.baseUrl}`,
detailedMessages: { data: response.data }
@@ -134,7 +135,8 @@ export default class CPOEMSPCredentialsService {
}
// If not found trigger exception
if (!versionFound) {
- throw new BackendError({
+ throw new AppError({
+ errorCode: StatusCodes.NOT_FOUND,
module: MODULE_NAME, method: 'handleUpdateCreateCredentials', action,
message: 'OCPI Endpoint version 2.1.1 not found',
detailedMessages: { data: response.data }

MODIFY
src/server/ocpi/service/cpo/v2.1.1/CPOTokensService.ts
src/server/ocpi/service/cpo/v2.1.1/CPOTokensService.ts
@@ -35,7 +35,7 @@ export default class CPOTokensService {
if (!token) {
throw new AppError({
module: MODULE_NAME, method: 'handleGetToken', action,
- errorCode: StatusCodes.BAD_REQUEST,
+ errorCode: StatusCodes.NOT_FOUND,
message: `Token ID '${tokenId}' not found`,
ocpiError: OCPIStatusCode.CODE_2001_INVALID_PARAMETER_ERROR
});
@@ -75,7 +75,7 @@ export default class CPOTokensService {
if (!tag) {
throw new AppError({
module: MODULE_NAME, method: 'handlePutToken', action,
- errorCode: StatusCodes.BAD_REQUEST,
+ errorCode: StatusCodes.NOT_FOUND,
message: `Token ID '${tokenId}' not found`,
ocpiError: OCPIStatusCode.CODE_2001_INVALID_PARAMETER_ERROR,
detailedMessages: { token }

MODIFY
src/server/ocpi/service/emsp/v2.1.1/EMSPSessionsService.ts
src/server/ocpi/service/emsp/v2.1.1/EMSPSessionsService.ts
@@ -100,7 +100,7 @@ export default class EMSPSessionsService {
if (!transaction) {
throw new AppError({
module: MODULE_NAME, method: 'handlePatchSession', action,
- errorCode: HTTPError.GENERAL_ERROR,
+ errorCode: StatusCodes.NOT_FOUND,
message: `Transaction not found with OCPI Session ID '${sessionID}'`,
ocpiError: OCPIStatusCode.CODE_2001_INVALID_PARAMETER_ERROR
});

MODIFY
src/server/ocpi/service/emsp/v2.1.1/EMSPTariffsService.ts
src/server/ocpi/service/emsp/v2.1.1/EMSPTariffsService.ts
@@ -40,7 +40,7 @@ export default class EMSPTariffsService {
} else {
throw new AppError({
module: MODULE_NAME, method: 'handleGetTariff', action,
- errorCode: StatusCodes.BAD_REQUEST,
+ errorCode: StatusCodes.NOT_FOUND,
message: `Simple Pricing setting not found in Tenant ${Utils.buildTenantName(tenant)}`,
ocpiError: OCPIStatusCode.CODE_3000_GENERIC_SERVER_ERROR
});

Return right OCPI Http codes