Skip to content

Commit

Permalink
IMN-866 - Tenant quick fixes - fixing some 404 error mappers (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecamellini authored Oct 7, 2024
1 parent 35306aa commit c25f9f0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/tenant-process/src/utilities/errorMappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getTenantByExternalIdErrorMapper = (
error: ApiError<ErrorCodes>
): number =>
match(error.code)
.with("tenantNotFound", () => HTTP_STATUS_NOT_FOUND)
.with("tenantNotFoundByExternalId", () => HTTP_STATUS_NOT_FOUND)
.otherwise(() => HTTP_STATUS_INTERNAL_SERVER_ERROR);

export const getTenantBySelfcareIdErrorMapper = (
Expand Down Expand Up @@ -191,7 +191,12 @@ export const m2mUpsertTenantErrorMapper = (
error: ApiError<ErrorCodes>
): number =>
match(error.code)
.with("tenantNotFound", "attributeNotFound", () => HTTP_STATUS_NOT_FOUND)
.with(
"tenantNotFound",
"attributeNotFound",
"tenantNotFoundByExternalId",
() => HTTP_STATUS_NOT_FOUND
)
.with("certifiedAttributeAlreadyAssigned", () => HTTP_STATUS_CONFLICT)
.with("tenantIsNotACertifier", () => HTTP_STATUS_FORBIDDEN)
.otherwise(() => HTTP_STATUS_INTERNAL_SERVER_ERROR);
Expand All @@ -217,6 +222,10 @@ export const m2mRevokeCertifiedAttributeErrorMapper = (
"tenantNotFoundByExternalId",
() => HTTP_STATUS_NOT_FOUND
)
.with("attributeNotFoundInTenant", () => HTTP_STATUS_BAD_REQUEST)
.with(
"attributeNotFound",
"attributeNotFoundInTenant",
() => HTTP_STATUS_BAD_REQUEST
)
.with("tenantIsNotACertifier", () => HTTP_STATUS_FORBIDDEN)
.otherwise(() => HTTP_STATUS_INTERNAL_SERVER_ERROR);

0 comments on commit c25f9f0

Please sign in to comment.