From 27c2c240d1c0080da474f3da0c3ed4c0cda92fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Sat, 7 Jun 2014 14:32:51 +0200 Subject: [PATCH] [enh] Prepend a message with argument name on check pattern failure --- locales/en.json | 1 + locales/fr.json | 1 + moulinette/actionsmap.py | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/locales/en.json b/locales/en.json index 6d0755ec..408ec0cf 100644 --- a/locales/en.json +++ b/locales/en.json @@ -15,6 +15,7 @@ "ldap_attribute_already_exists" : "Attribute already exists: '{:s}={:s}'", "argument_required" : "Argument {:s} is required", + "invalid_argument": "Invalid argument '{:s}': {:s}", "password" : "Password", "invalid_password" : "Invalid password", "confirm" : "Confirm {:s}", diff --git a/locales/fr.json b/locales/fr.json index 232ec6e7..b853ccd8 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -15,6 +15,7 @@ "ldap_attribute_already_exists" : "L'attribut existe déjà : '{:s}={:s}'", "argument_required" : "L'argument {:s} est requis", + "invalid_argument": "Argument '{:s}' incorrect : {:s}", "password" : "Mot de passe", "invalid_password" : "Mot de passe incorrect", "confirm" : "Confirmez le {:s}", diff --git a/moulinette/actionsmap.py b/moulinette/actionsmap.py index 579dce26..02b942b7 100644 --- a/moulinette/actionsmap.py +++ b/moulinette/actionsmap.py @@ -152,7 +152,8 @@ class PatternParameter(_ExtraParameter): v = arg_value if v and not re.match(pattern, v or '', re.UNICODE): - raise MoulinetteError(errno.EINVAL, m18n.n(message)) + raise MoulinetteError(errno.EINVAL, m18n.g('invalid_argument', + arg_name, m18n.n(message))) return arg_value @staticmethod