From c682f9d16d30d0aac4c26e4774ab80c54e21fe03 Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Wed, 9 Feb 2011 16:21:36 +0000 Subject: [PATCH] Allow to customize error_message passed to the user from ExternalValidator. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43238 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/Formulator/Errors.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/product/Formulator/Errors.py b/product/Formulator/Errors.py index 8ad8a15e1a..be4068b4b8 100644 --- a/product/Formulator/Errors.py +++ b/product/Formulator/Errors.py @@ -17,12 +17,15 @@ allow_class(FormValidationError) class ValidationError(Exception): - def __init__(self, error_key, field): + def __init__(self, error_key, field, error_text=None): Exception.__init__(self, error_key) self.error_key = error_key self.field_id = field.id self.field = field - self.error_text = field.get_error_message(error_key) + if error_text is not None: + self.error_text = error_text + else: + self.error_text = field.get_error_message(error_key) allow_class(ValidationError) -- 2.30.9