Browse Source

Changed error message to include actual exception contents

pull/1360/head
Keyan Pishdadian 10 years ago
parent
commit
1cd9e91810
  1. 2
      flask/wrappers.py
  2. 4
      tests/test_helpers.py

2
flask/wrappers.py

@ -177,7 +177,7 @@ class Request(RequestBase):
ctx = _request_ctx_stack.top ctx = _request_ctx_stack.top
if ctx is not None: if ctx is not None:
if ctx.app.config.get('DEBUG', False): 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() raise BadRequest()
def _load_form_data(self): def _load_form_data(self):

4
tests/test_helpers.py

@ -59,7 +59,7 @@ class TestJSON(object):
c = app.test_client() c = app.test_client()
rv = c.post('/json', data=None, content_type='application/json') rv = c.post('/json', data=None, content_type='application/json')
assert rv.status_code == 400 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): def test_post_empty_json_wont_add_exception_to_response_if_no_debug(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -71,7 +71,7 @@ class TestJSON(object):
c = app.test_client() c = app.test_client()
rv = c.post('/json', data=None, content_type='application/json') rv = c.post('/json', data=None, content_type='application/json')
assert rv.status_code == 400 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): def test_json_bad_requests(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)

Loading…
Cancel
Save