Merge pull request 'feat: refs #7323 show right error' (!3096) from 7323-showRightError into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #3096
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Jorge Penadés 2024-10-14 13:31:59 +00:00
commit d02e942dd2
1 changed files with 1 additions and 0 deletions

View File

@ -217,6 +217,7 @@ module.exports = Self => {
const code = e.code;
const message = e.sqlMessage;
if (e.message && e.message.includes('Invalid email')) throw new UserError('Invalid email');
if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`This personal mail already exists`);
if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`)) throw new UserError(`This worker code already exists`);
if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) throw new UserError(`This worker already exists`);