diff --git a/client/src/i18n/en.json b/client/src/i18n/en.json index a9acf85827..fcfc3e259a 100644 --- a/client/src/i18n/en.json +++ b/client/src/i18n/en.json @@ -249,7 +249,17 @@ "NOT_FOUND" : "This record could not be found", "UNAUTHORIZED" : "You have submitted a bad username and password combination. Please login in with valid credentials to continue.", "UNKNOWN" : "An error occurred.", - "OVERPAID_INVOICE" : "You have overpaid the invoices." + "OVERPAID_INVOICE" : "You have overpaid the invoices.", + "ER_DUP_KEY" : "A key collided in a unique database field. Please retry your action. If the problem persists, contact the developers.", + "ER_DUP_ENTRY" : "You have duplicated a value in a unique field! Please make sure that the necessary values are unique.", + "ER_BAD_FIELD_ERROR" : "Column does not exist in database.", + "ER_ROW_IS_REFERENCED" : "Cannot delete entity because entity is used in another table.", + "ER_ROW_IS_REFERENCED_2" : "Cannot delete entity because entity is used in another table.", + "ER_BAD_NULL_ERROR" : "A column was left NULL that cannot be NULL.", + "ER_PARSE_ERROR" : "Your request could not be translated into valid SQL. Please modify your request and try again.", + "ER_EMPTY_QUERY" : "Your request seems empty. Are you sure you filled everything in?", + "ER_NO_DEFAULT_FOR_FIELD" : "You did not include enough information in your submission! Please check your errors and try again.", + "ER_DATA_TOO_LONG" : "One of your form values is too long! Please shorten it and resubmit." }, "EXCHANGE": { "ADDING_RATE" : "Adding an exchange Rate", diff --git a/client/src/i18n/fr.json b/client/src/i18n/fr.json index c841a879ca..c1780c1d43 100644 --- a/client/src/i18n/fr.json +++ b/client/src/i18n/fr.json @@ -254,7 +254,17 @@ "NOT_FOUND" : "Cet enregistrement n'a pas pu être trouvé", "UNAUTHORIZED" : "Vous avez soumis une mauvais nom et mot de passe. Entrez un nom et mot de passe valid pour continuer.", "UNKNOWN" : "Une erreur est survenue.", - "OVERPAID_INVOICE" : "Vous avez payé trop aux factures." + "OVERPAID_INVOICE" : "Vous avez payé trop aux factures.", + "ER_DUP_KEY" : "Il ya déjà un enregistrement avec cette clé. Veuillez réessayer votre action. Si le problème persiste, contactez les développeurs.", + "ER_DUP_ENTRY" : "Vous avez dupliqué une valeur dans un champ unique! Assurez-vous que les valeurs nécessaires sont uniques.", + "ER_BAD_FIELD_ERROR" : "Vous avez entré un champ qui ne peut pas être stocké dans la base de données.", + "ER_ROW_IS_REFERENCED" : "Vous ne pouvez pas supprimer cet enregistrement référencé par un autre enregistrement dans la base de données.", + "ER_ROW_IS_REFERENCED_2" :"Vous ne pouvez pas supprimer cet enregistrement référencé par un autre enregistrement dans la base de données.", + "ER_BAD_NULL_ERROR" : "Un champ a été laissé vide qui ne peut pas être vide.", + "ER_PARSE_ERROR" : "Votre demande n'a pas été comprise. Veuillez modifier votre demande et réessayer.", + "ER_EMPTY_QUERY" : "Votre demande semble vide. Êtes-vous sûr de remplir tout?", + "ER_NO_DEFAULT_FOR_FIELD" : "Vous n'avez pas inclus suffisamment d'informations dans votre soumission! Veuillez vérifier vos erreurs et réessayer.", + "ER_DATA_TOO_LONG" : "Une de vos valeurs de formulaire est trop longue! Veuillez le raccourcir et le renvoyer." }, "EXCHANGE": { "ADDING_RATE" : "Ajout d'un taux", diff --git a/server/config/interceptors.js b/server/config/interceptors.js index 0fb05cec5f..0b8d37f53a 100644 --- a/server/config/interceptors.js +++ b/server/config/interceptors.js @@ -1,3 +1,5 @@ +'use strict'; + /** * @overview interceptors * This modules defines a unified error handler for the server. @@ -10,7 +12,6 @@ * @requires winston * @requires BadRequest */ -'use strict'; const winston = require('winston'); const BadRequest = require('../lib/errors/BadRequest'); @@ -21,11 +22,11 @@ const map = { `A key collided in a unique database field. Please retry your action. If the problem persists, contact the developers.`, ER_BAD_FIELD_ERROR : 'Column does not exist in database.', + ER_ROW_IS_REFERENCED : + 'Cannot delete entity because entity is used in another table.', ER_ROW_IS_REFERENCED_2 : 'Cannot delete entity because entity is used in another table.', ER_BAD_NULL_ERROR : 'A column was left NULL that cannot be NULL.', - ER_DUP_ENTRY : - 'You cannot insert a duplicate record. This record already exists.', ER_PARSE_ERROR : `Your request could not be translated into valid SQL. Please modify your request and try again.`, @@ -66,7 +67,7 @@ exports.handler = function handler(error, req, res, next) { key = SQL_STATES[error.sqlState]; description = error.toString(); } else { - key = 'ERRORS.BAD_REQUEST'; + key = `ERRORS.${error.code}`; description = map[error.code]; } diff --git a/test/integration/depots.js b/test/integration/depots.js index a1c5dd52e2..6ae2046e8c 100644 --- a/test/integration/depots.js +++ b/test/integration/depots.js @@ -71,7 +71,7 @@ describe('(/depots) The depots API ', function () { .send(badDepot) .then(function (res) { helpers.api.errored(res, 400); - expect(res.body.code).to.be.equal('ERRORS.BAD_REQUEST'); + expect(res.body.code).to.be.equal('ERRORS.ER_NO_DEFAULT_FOR_FIELD'); }) .catch(helpers.handler); }); diff --git a/test/integration/priceList.js b/test/integration/priceList.js index 2699b6d4b1..31ae6c1a1f 100644 --- a/test/integration/priceList.js +++ b/test/integration/priceList.js @@ -176,7 +176,7 @@ describe('(/prices ) Price List', function () { .then(function (res) { helpers.api.errored(res, 400); - expect(res.body.code).to.equal('ERRORS.BAD_REQUEST'); + expect(res.body.code).to.equal('ERRORS.ER_BAD_NULL_ERROR'); // make sure we didn't gain a price list! return agent.get('/prices'); diff --git a/test/integration/users.js b/test/integration/users.js index acdb596553..1d9db108b7 100644 --- a/test/integration/users.js +++ b/test/integration/users.js @@ -50,7 +50,7 @@ describe('(/users) Users and Permissions', function () { return agent.post('/users') .send(badUser) .then(function (res) { - helpers.api.errored(res, 400, 'ERRORS.BAD_REQUEST'); + helpers.api.errored(res, 400, 'ERRORS.ER_BAD_NULL_ERROR'); }) .catch(helpers.handler); }); @@ -76,7 +76,7 @@ describe('(/users) Users and Permissions', function () { return agent.get('/users/' + newUser.id) .then(function (res) { expect(res).to.have.status(200); - expect(res).to.be.json; + expect(res).to.be.json; expect(res.body.email).to.equal(newUser.email); expect(res.body.display_name).to.equal(newUser.display_name); })