Skip to content

Commit e45b899

Browse files
committed
feat: 1103 confirmation demande agrement (retours revue)
1 parent c4ba9a9 commit e45b899

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/backend/src/usagers/agrements/agrements.repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export const AgrementsRepository = {
258258
*/
259259
async getById(
260260
agrementId: number,
261-
): Promise<AgrementEntity & { user_mail: string | null }> {
261+
): Promise<(AgrementEntity & { user_mail: string | null }) | null> {
262262
const client = await getPool().connect();
263263
try {
264264
const result = await client.query(
@@ -272,7 +272,7 @@ export const AgrementsRepository = {
272272
[agrementId],
273273
);
274274
if (result.rows.length === 0) {
275-
throw new Error("Aucun agrément trouvé avec cet ID");
275+
return null;
276276
}
277277
return result.rows[0] as AgrementEntity & { user_mail: string | null };
278278
} finally {

packages/backend/src/usagers/agrements/agrements.service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,9 @@ export const AgrementService = {
9898
statut: AGREMENT_STATUT;
9999
usagerUserId: string;
100100
}): Promise<boolean> {
101-
let agrement;
102-
try {
103-
agrement = await AgrementsRepository.getById(agrementId);
104-
} catch (err) {
105-
log.w("Erreur lors de la récupération de l'agrément", err);
101+
const agrement = await AgrementsRepository.getById(agrementId);
102+
if (!agrement) {
103+
log.w("Agrement non trouvé", agrementId);
106104
throw new AppError("Agrement non trouvé", { statusCode: 404 });
107105
}
108106

0 commit comments

Comments
 (0)