File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
packages/backend/src/usagers/agrements Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments