[ckan-changes] commit/ckan: dread: [lib/base][s]: #1312 Improve error message for json decoding when the character encoding is problematic.
Bitbucket
commits-noreply at bitbucket.org
Tue Sep 6 16:48:16 UTC 2011
1 new changeset in ckan:
http://bitbucket.org/okfn/ckan/changeset/55273629a552/
changeset: 55273629a552
user: dread
date: 2011-09-06 18:43:19
summary: [lib/base][s]: #1312 Improve error message for json decoding when the character encoding is problematic.
affected #: 1 file (299 bytes)
--- a/ckan/lib/base.py Mon Sep 05 19:21:02 2011 +0100
+++ b/ckan/lib/base.py Tue Sep 06 17:43:19 2011 +0100
@@ -182,7 +182,13 @@
msg = _("No request body data")
raise ValueError, msg
if request_data:
- request_data = json.loads(request_data, encoding='utf8')
+ try:
+ request_data = json.loads(request_data, encoding='utf8')
+ except ValueError, e:
+ raise ValueError, _('Error parsing JSON data. '
+ 'Error: %r '
+ 'JSON (Decoded and re-encoded): %r' % \
+ (e, request_data))
if not isinstance(request_data, dict):
raise ValueError, _("Request params must be in form of a json encoded dictionary.")
# ensure unicode values
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list