From cd214b3526d204581562730405e17451b7897122 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 11:11:22 +0100 Subject: [PATCH] fix: refs #7028 fix userError --- loopback/locale/es.json | 4 +++- modules/ticket/back/methods/ticket-request/deny.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e0b180544..d7fcb8805 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -394,5 +394,7 @@ "Price cannot be blank": "Price cannot be blank", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", - "Worker not found": "Trabajador no encontrado" + "Worker not found": "Trabajador no encontrado", + "Invalid request or related ticket/client data": "Solicitud no válida o datos de ticket/cliente relacionados" + } diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index f151afd6b..c6a1d35af 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('deny', { description: 'Sets a ticket request to denied and returns the changes', @@ -43,7 +44,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; const worker = await models.Worker.findById(userId, myOptions); - if (!worker) throw new Error('Worker not found'); + if (!worker) throw new UserError('Worker not found'); const params = { isOk: false, @@ -66,7 +67,7 @@ module.exports = Self => { }, myOptions); if (!request || !request.ticket() || !request.ticket().client()) - throw new Error('Invalid request or related ticket/client data'); + throw new UserError('Invalid request or related ticket/client data'); const url = await models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk;