[IMP] ir_http better exception handling for http errors
authorAntony Lesuisse <al@openerp.com>
Sun, 10 Nov 2013 13:57:39 +0000 (14:57 +0100)
committerAntony Lesuisse <al@openerp.com>
Sun, 10 Nov 2013 13:57:39 +0000 (14:57 +0100)
bzr revid: al@openerp.com-20131110135739-2tmr6iynil16ooi1

openerp/addons/base/ir/ir_http.py

index d6c76b1..6f77f9f 100644 (file)
@@ -131,8 +131,13 @@ class ir_http(osv.AbstractModel):
         try:
             request.set_handler(func, arguments, auth_method)
             result = request.dispatch()
+        except werkzeug.exceptions.HTTPException, e:
+            fn = getattr(self, '_handle_%s' % (e.code,), None)
+            if fn:
+                return fn(e)
+            return self._handle_500(e)
         except Exception, e:
-            return  self._handle_500(e)
+            return self._handle_500(e)
         return result
 
 # vim:et: