mejorando manejo de errores aun mas
Some checks failed
build-and-deploy / filter (push) Successful in 2s
Sync to GitHub / sync (push) Failing after 2s
build-and-deploy / build (push) Successful in 12s
build-and-deploy / deploy (push) Successful in 14s

This commit is contained in:
2025-05-30 13:03:53 -06:00
parent 49829d9d2e
commit 0bcc340043
4 changed files with 10 additions and 11 deletions

View File

@@ -74,10 +74,11 @@ router.post('/', async (req, res) => {
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError) {
if (e.code === 'P2003') {
if (e.meta?.field_name?.includes('empleado_id')) {
const constraint = e.meta?.constraint || '';
if (constraint.includes('empleado_id')) {
return res.status(400).json({ message: 'El empleado_id proporcionado no existe.' });
}
if (e.meta?.field_name?.includes('planilla_id')) {
if (constraint.includes('planilla_id')) {
return res.status(400).json({ message: 'El planilla_id proporcionado no existe.' });
}
}