Skip to content

Commit 5fa01fa

Browse files
Revert "WIP Remove id from Error?"
This reverts commit ded48aa.
1 parent ff77676 commit 5fa01fa

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lambdas/api-handler/src/contracts/errors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { randomUUID } from 'crypto';
22

33
export interface ApiError {
4+
id: string;
45
code: ApiErrorCode;
56
links: {about: 'https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier'};
67
status: ApiErrorStatus;
@@ -45,6 +46,7 @@ export function buildApiError(params: {
4546
detail: ApiErrorDetail | string;
4647
}): ApiError {
4748
return {
49+
id: randomUUID(), // TODO CCM-11188: correlation ID?
4850
code: params.code,
4951
links: { about: 'https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier' },
5052
status: params.status,

lambdas/api-handler/src/mappers/__tests__/error-mapper.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe("mapErrorToResponse", () => {
1414
{
1515
"code": "NOTIFY_INVALID_REQUEST",
1616
"detail": "The letter ID in the request body does not match the letter ID path parameter",
17+
"id": expect.any(String),
1718
"links": {
1819
"about": "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier"
1920
},
@@ -35,6 +36,7 @@ describe("mapErrorToResponse", () => {
3536
{
3637
"code": "NOTIFY_LETTER_NOT_FOUND",
3738
"detail": "The provided letter ID does not exist for the supplier",
39+
"id": expect.any(String),
3840
"links": {
3941
"about": "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier"
4042
},
@@ -56,6 +58,7 @@ describe("mapErrorToResponse", () => {
5658
{
5759
"code": "NOTIFY_INTERNAL_SERVER_ERROR",
5860
"detail": "Something broke",
61+
"id": expect.any(String),
5962
"links": {
6063
"about": "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier"
6164
},
@@ -77,6 +80,7 @@ describe("mapErrorToResponse", () => {
7780
{
7881
"code": "NOTIFY_INTERNAL_SERVER_ERROR",
7982
"detail": "Unexpected error",
83+
"id": expect.any(String),
8084
"links": {
8185
"about": "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier"
8286
},

0 commit comments

Comments
 (0)