From d0877903dc7e39f4e0fdbe536270f9901ec7efa6 Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Fri, 2 May 2025 14:50:19 +0530 Subject: [PATCH] modified exception handling --- src/auth/auth.service.ts | 6 +++--- src/main.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 616cabb..ee85d29 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -50,18 +50,18 @@ export class AuthService { await cursor.close(); } else { - return new BadRequestException({ + throw new BadRequestException({ Error: 'Error executing request try after some time!', }); } if (rows[0]['ERRORMESG']) { - return { error: 'Invalid username or password!' }; + throw new BadRequestException({ error: 'Invalid username or password!' }); } return { msg: 'Logged in successfully' }; } catch (err) { console.error('Error fetching users: ', err.message); - return { error: 'Invalid username or password' }; + throw new BadRequestException({ error: 'Invalid username or password' }); } finally { if (connection) { diff --git a/src/main.ts b/src/main.ts index 3107714..976d4dc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -56,7 +56,7 @@ async function bootstrap() { }) .filter(Boolean); - return new BadRequestException({ + throw new BadRequestException({ message: 'Validation failed', errors: newResult, });