Dup entry error handler
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-12-29 14:02:26 +01:00
parent a3f17ae302
commit c2d50c6044
1 changed files with 37 additions and 31 deletions

View File

@ -48,6 +48,7 @@ module.exports = Self => {
let stmts = [];
let stmt;
try {
stmt = new ParameterizedSQL(
`CALL travel_cloneWithEntries(?, ?, ?, ?, @vTravelFk)`, [
id, started, ended, travel.ref]);
@ -83,5 +84,10 @@ module.exports = Self => {
});
return newTravel.id;
} catch (error) {
if (error.code === 'ER_DUP_ENTRY')
throw new UserError('A travel with this data already exists');
throw error;
}
};
};