From 1cd9e91810fcfc3b3ca4e8c157593af28de427d6 Mon Sep 17 00:00:00 2001 From: Keyan Pishdadian Date: Thu, 5 Mar 2015 13:04:38 -0500 Subject: [PATCH] Changed error message to include actual exception contents --- flask/wrappers.py | 2 +- tests/test_helpers.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flask/wrappers.py b/flask/wrappers.py index df9d205c..fe0c7bcb 100644 --- a/flask/wrappers.py +++ b/flask/wrappers.py @@ -177,7 +177,7 @@ class Request(RequestBase): ctx = _request_ctx_stack.top if ctx is not None: if ctx.app.config.get('DEBUG', False): - raise BadRequest('No JSON object could be decoded') + raise BadRequest('Failed to decode JSON object: {}'.format(e)) raise BadRequest() def _load_form_data(self): diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 5867ab65..8d09327f 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -59,7 +59,7 @@ class TestJSON(object): c = app.test_client() rv = c.post('/json', data=None, content_type='application/json') assert rv.status_code == 400 - assert b'No JSON object could be decoded' in rv.data + assert b'Failed to decode JSON object' in rv.data def test_post_empty_json_wont_add_exception_to_response_if_no_debug(self): app = flask.Flask(__name__) @@ -71,7 +71,7 @@ class TestJSON(object): c = app.test_client() rv = c.post('/json', data=None, content_type='application/json') assert rv.status_code == 400 - assert b'No JSON object could be decoded' not in rv.data + assert b'Failed to decode JSON object' not in rv.data def test_json_bad_requests(self): app = flask.Flask(__name__)