modified exception handling
This commit is contained in:
parent
5368f4069d
commit
d0877903dc
@ -50,18 +50,18 @@ export class AuthService {
|
|||||||
|
|
||||||
await cursor.close();
|
await cursor.close();
|
||||||
} else {
|
} else {
|
||||||
return new BadRequestException({
|
throw new BadRequestException({
|
||||||
Error: 'Error executing request try after some time!',
|
Error: 'Error executing request try after some time!',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rows[0]['ERRORMESG']) {
|
if (rows[0]['ERRORMESG']) {
|
||||||
return { error: 'Invalid username or password!' };
|
throw new BadRequestException({ error: 'Invalid username or password!' });
|
||||||
}
|
}
|
||||||
return { msg: 'Logged in successfully' };
|
return { msg: 'Logged in successfully' };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching users: ', err.message);
|
console.error('Error fetching users: ', err.message);
|
||||||
return { error: 'Invalid username or password' };
|
throw new BadRequestException({ error: 'Invalid username or password' });
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (connection) {
|
if (connection) {
|
||||||
|
|||||||
@ -56,7 +56,7 @@ async function bootstrap() {
|
|||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
return new BadRequestException({
|
throw new BadRequestException({
|
||||||
message: 'Validation failed',
|
message: 'Validation failed',
|
||||||
errors: newResult,
|
errors: newResult,
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user