Skip to content

Commit

Permalink
[PRMT-4832] Added enhanced logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-nhs committed May 10, 2024
1 parent 78bdf58 commit 6d3fa50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
15 changes: 5 additions & 10 deletions src/services/fhir/__tests__/sds-fhir-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ describe('sds-fhir-client', () => {
await expect(getPracticeAsid(odsCode, serviceId)).rejects.toThrow(errorMessage);
expect(scope.isDone()).toBe(true);
expect(logError).toHaveBeenCalledWith(
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode}`,
errorMessage
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode} - error: ${errorMessage.message}`
);
});

Expand All @@ -132,8 +131,7 @@ describe('sds-fhir-client', () => {
await expect(getPracticeAsid(odsCode, serviceId)).rejects.toThrow(errorMessage);
expect(scope.isDone()).toBe(true);
expect(logError).toHaveBeenCalledWith(
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode}`,
errorMessage
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode} - error: ${errorMessage.message}`
);
});

Expand All @@ -154,8 +152,7 @@ describe('sds-fhir-client', () => {
await expect(getPracticeAsid(odsCode, serviceId)).rejects.toThrow(errorMessage);
expect(scope.isDone()).toBe(true);
expect(logError).toHaveBeenCalledWith(
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode}`,
errorMessage
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode} - error: ${errorMessage.message}`
);
});

Expand All @@ -176,8 +173,7 @@ describe('sds-fhir-client', () => {
await expect(getPracticeAsid(odsCode, serviceId)).rejects.toThrow(errorMessage);
expect(scope.isDone()).toBe(true);
expect(logError).toHaveBeenCalledWith(
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode}`,
errorMessage
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode} - error: ${errorMessage.message}`
);
});

Expand All @@ -198,8 +194,7 @@ describe('sds-fhir-client', () => {
await expect(getPracticeAsid(odsCode, serviceId)).rejects.toThrow(errorMessage);
expect(scope.isDone()).toBe(true);
expect(logError).toHaveBeenCalledWith(
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode}`,
errorMessage
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode} - error: ${errorMessage.message}`
);
});
});
8 changes: 5 additions & 3 deletions src/services/fhir/sds-fhir-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ export const getPracticeAsid = async (odsCode, serviceId) => {
logInfo(`Successfully retrieved ASID: ${asidCode} via FHIR for ODS code ${odsCode}`);
return asidCode;
} catch (err) {
logError(`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode}`);
logError(`Error details: ${err.message ? err.message : 'No Error Message'}`);

logError(
`Failed to retrieve ASID from FHIR for ODS Code: ${odsCode} - error: ${
err.message ? err.message : 'No Error Message'
}`
);
if (err.response) {
logError(
`Error: Request failed with non-2xx status code\n
Expand Down

0 comments on commit 6d3fa50

Please sign in to comment.