# HG changeset patch # User Julien Cristau # Date 1394726595 -3600 # Node ID f79ce7b39ee9e4cebb9a3eb7bef1e465c3de566a # Parent 33f6ad4c75a5bf07cf27c583be96bb4e5f0d3a05 [web/ajax] Always return a json dict with a 'reason' key in case of ajax errors Sending sometimes a bare unicode string and sometimes a json-encoded dict seems like a bad idea. diff -r 33f6ad4c75a5 -r f79ce7b39ee9 web/application.py --- a/web/application.py Thu Mar 13 17:01:58 2014 +0100 +++ b/web/application.py Thu Mar 13 17:03:15 2014 +0100 @@ -23,6 +23,7 @@ from time import clock, time from contextlib import contextmanager from warnings import warn +import json import httplib @@ -584,7 +585,7 @@ if req.status_out < 400: # don't overwrite it if it's already set req.status_out = status - json_dumper = getattr(ex, 'dumps', lambda : unicode(ex)) + json_dumper = getattr(ex, 'dumps', lambda : json.dumps({'reason': unicode(ex)})) return json_dumper() # special case handling