From b6e7eeb1800da89ab413f91b41d82f0b4df7b072 Mon Sep 17 00:00:00 2001 From: Jakub Dubec Date: Tue, 7 Jan 2020 10:11:39 +0100 Subject: [PATCH] =?UTF-8?q?Invalid=20value=20error=20=F0=9F=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ django_request_formatter/forms.py | 3 +++ django_request_formatter/version.py | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01b7e9c..27ae6fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.5.7 : 07.01.2020 + +- **Fix**: Introduced generic `Invalid value` error message, if there is `AttributeError`, `TypeError`, `ValueError` + ## 0.5.6 : 01.01.2020 - **Fix**: Fixing issue from version `0.5.5` but this time for real diff --git a/django_request_formatter/forms.py b/django_request_formatter/forms.py index 6b6330c..f5bed43 100644 --- a/django_request_formatter/forms.py +++ b/django_request_formatter/forms.py @@ -6,6 +6,7 @@ import msgpack from django.core.exceptions import ValidationError, NON_FIELD_ERRORS from django.forms import MediaDefiningClass, Field +from django.utils.translation import gettext from django_request_formatter.exceptions import RequestValidationError @@ -147,6 +148,8 @@ def full_clean(self): self.cleaned_data[key] = getattr(self, f"clean_{key}")() except (ValidationError, RequestValidationError) as e: self.add_error(key, e) + except (AttributeError, TypeError, ValueError): + self.add_error(key, gettext("Invalid value")) try: cleaned_data = self.clean() diff --git a/django_request_formatter/version.py b/django_request_formatter/version.py index 8701e4d..22e3a83 100644 --- a/django_request_formatter/version.py +++ b/django_request_formatter/version.py @@ -1 +1 @@ -__version__ = '0.5.6' +__version__ = '0.5.7'