[FIX] Do not assume all exceptions with a code attribute to be HTTPExceptions

This commit is contained in:
Fabien Meghazi
2014-08-20 15:24:34 +02:00
parent 154867daad
commit af3f56684f
+8 -6
View File
@@ -190,7 +190,14 @@ class ir_http(orm.AbstractModel):
exception=exception,
traceback=traceback.format_exc(exception),
)
code = getattr(exception, 'code', code)
if isinstance(exception, werkzeug.exceptions.HTTPException):
if exception.code is None:
# Hand-crafted HTTPException likely coming from abort(),
# usually for a redirect response -> return it directly
return exception
else:
code = exception.code
if isinstance(exception, openerp.exceptions.AccessError):
code = 403
@@ -200,11 +207,6 @@ class ir_http(orm.AbstractModel):
if isinstance(exception.qweb.get('cause'), openerp.exceptions.AccessError):
code = 403
if isinstance(exception, werkzeug.exceptions.HTTPException) and code is None:
# Hand-crafted HTTPException likely coming from abort(),
# usually for a redirect response -> return it directly
return exception
if code == 500:
logger.error("500 Internal Server Error:\n\n%s", values['traceback'])
if 'qweb_exception' in values: