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, });