[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.
--- 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