Skip to content

Commit

Permalink
IMN-608 - Fixing error in contract creation in case of attribute not …
Browse files Browse the repository at this point in the history
…found (#612)
  • Loading branch information
ecamellini authored Jun 5, 2024
1 parent c35e9cb commit b1da93b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/agreement-process/src/model/domain/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
makeApiProblemBuilder,
UserId,
SelfcareId,
AttributeId,
} from "pagopa-interop-models";

export const errorCodes = {
Expand Down Expand Up @@ -297,3 +298,13 @@ export function userNotFound(
title: "User not found",
});
}

export function attributeNotFound(
attributeId: AttributeId
): ApiError<ErrorCodes> {
return new ApiError({
detail: `Attribute ${attributeId} not found`,
code: "attributeNotFound",
title: "Attribute not found",
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
VerifiedTenantAttribute,
UserId,
generateId,
genericError,
tenantAttributeType,
unsafeBrandId,
AgreementDocument,
Expand All @@ -38,6 +37,7 @@ import {
agreementMissingUserInfo,
agreementSelfcareIdNotFound,
agreementStampNotFound,
attributeNotFound,
userNotFound,
} from "../model/domain/errors.js";
import { UpdateAgreementSeed } from "../model/domain/models.js";
Expand Down Expand Up @@ -105,7 +105,7 @@ const getAttributeInvolved = async (
tenantAttribute.id
);
if (!attribute) {
throw genericError(`Attribute ${tenantAttribute.id} not found`);
throw attributeNotFound(tenantAttribute.id);
}
return [attribute, tenantAttribute as unknown as T];
})
Expand Down

0 comments on commit b1da93b

Please sign in to comment.