mejorando manejo de errores aun mas
This commit is contained in:
@@ -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.' });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user