[web/ajax] don't override any status code with 500 in ajax_error_handler
authorJulien Cristau <julien.cristau@logilab.fr>
Thu, 13 Mar 2014 17:01:58 +0100
changeset 9727 33f6ad4c75a5
parent 9726 8905267dc7ae
child 9728 f79ce7b39ee9
[web/ajax] don't override any status code with 500 in ajax_error_handler If the request produced an error such as Unauthorized or NotFound, core_handle sets an appropriate status_out. Which is then overridden by the ajax error handler.
web/application.py
--- a/web/application.py	Fri Mar 14 11:11:28 2014 +0100
+++ b/web/application.py	Thu Mar 13 17:01:58 2014 +0100
@@ -581,7 +581,9 @@
         status = httplib.INTERNAL_SERVER_ERROR
         if isinstance(ex, PublishException) and ex.status is not None:
             status = ex.status
-        req.status_out = status
+        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))
         return json_dumper()