Skip to content

Commit

Permalink
Merge pull request #11 from Hipo/fix-django-validation-error-response
Browse files Browse the repository at this point in the history
Update get_fallback_message for Django ValidationError
  • Loading branch information
efe authored Dec 9, 2019
2 parents 567f106 + 067667c commit 7c323eb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [0.1.3] - 2019-12-09

- Fix fallback_message of Django [ValidationError](https://github.com/Hipo/hipo-drf-exceptions/issues/10).

[0.1.3]: https://pypi.org/project/hipo-drf-exceptions/0.1.3/

## [0.1.2] - 2019-10-17

- Fix [bulk exceptions](https://github.com/Hipo/hipo-drf-exceptions/issues/9).
Expand Down
2 changes: 1 addition & 1 deletion hipo_drf_exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.1.2'
__version__ = '0.1.3'

from hipo_drf_exceptions.handlers import handler
from hipo_drf_exceptions.exceptions import BaseAPIException
3 changes: 3 additions & 0 deletions hipo_drf_exceptions/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def get_fallback_message(exception):
elif isinstance(exception, Exception):
if hasattr(exception, "detail"):
return get_fallback_message(exception.detail)
elif hasattr(exception, "message"):
# Handle Django ValidationError message attribute
return get_fallback_message(exception.message)

return exception.__str__()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hipo-drf-exceptions"
version = "0.1.2"
version = "0.1.3"
description = "A Django app for returning consistent, verbose and easy to parse error messages on Django Rest Framework backends."
authors = ["Hipo <pypi@hipolabs.com>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 7c323eb

Please sign in to comment.