From dc561aae036e03dbec9d4085ce2baaa9286f530b Mon Sep 17 00:00:00 2001 From: fja-odoo Date: Tue, 11 Jun 2019 12:26:48 +0000 Subject: [PATCH] [IMP] website: enhance http error pages - The traceback is only visible if in debug mode or if edit mode. - All except_orm exceptions are now displayed as a 400 but the AccessError wich is a 403. There is now a dedicted page for the 400 error. - Errors messages are no longer the exception args but its name if the exception is an except_orm. Else there is no message since the current logic override exceptions of type Exception in ir_http thus we have no message to display. Part of https://github.com/odoo/odoo/pull/32132 task-1894820 --- addons/website/models/ir_http.py | 7 +++ addons/website/views/website_templates.xml | 64 ++++++++++++++-------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index e6eb9c10fa9..a00221596b4 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -214,6 +214,11 @@ class Http(models.AbstractModel): traceback=traceback.format_exc(), ) + # only except_orm exceptions contain a message + if isinstance(exception, odoo.exceptions.except_orm): + values['error_message'] = exception.name + code = 400 + if isinstance(exception, werkzeug.exceptions.HTTPException): if exception.code is None: # Hand-crafted HTTPException likely coming from abort(), @@ -279,6 +284,8 @@ class Http(models.AbstractModel): values['editable'] = request.uid and request.website.is_publisher() elif code == 403: logger.warn("403 Forbidden:\n\n%s", values['traceback']) + elif code == 400: + logger.warn("400 Bad Request:\n\n%s", values['traceback']) try: html = env['ir.ui.view'].render_template('website.%s' % view_id, values) except Exception: diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index aa264dd76a7..c7d1b9fb19b 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -911,19 +911,22 @@ + + + + @@ -982,7 +1004,7 @@
-

404: Page not found!

+

404: Page not found!

The page you were looking for could not be found; it is possible you have typed the address incorrectly, but it has most probably been removed due @@ -995,10 +1017,6 @@

- - - -