Browse Source

Overwrite web error message to hide traceback from user

Inject sentry_activated into web session
Overwrite CrashManager.error QWeb template
Provide translations

Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>
pull/44/head
Sandy Carter 10 years ago
parent
commit
f72ba9e69f
  1. 13
      sentry_logger/__init__.py
  2. 8
      sentry_logger/__openerp__.py
  3. 32
      sentry_logger/i18n/fr.po
  4. 30
      sentry_logger/i18n/sentry_logger.pot
  5. 25
      sentry_logger/static/src/xml/base.xml

13
sentry_logger/__init__.py

@ -24,6 +24,7 @@ import logging
import cgitb
from openerp.tools import config
from openerp.addons.web.controllers.main import Session
from .odoo_sentry_client import OdooClient
from .odoo_sentry_handler import OdooSentryHandler
@ -49,3 +50,15 @@ if config.get(u'sentry_dsn'):
else:
root_logger.warn(u"Sentry DSN not defined in config file")
client = None
# Inject sentry_activated to session to display error message or not
old_session_info = Session.session_info
def session_info(self, req):
res = old_session_info(self, req)
res['sentry_activated'] = bool(client)
return res
Session.session_info = session_info

8
sentry_logger/__openerp__.py

@ -21,7 +21,7 @@
##############################################################################
{
'name': "sentry",
'name': "Sentry Logger",
'summary': "Sentry integration",
'description': """
@ -47,7 +47,7 @@ Contributors
'version': '1.0',
# any module necessary for this one to work correctly
'depends': ['base'],
'depends': ['web'],
'external_dependencies': {
'python': ['raven', 'raven_sanitize_openerp', 'bzrlib', 'git'],
},
@ -57,6 +57,10 @@ Contributors
'demo': [
],
'qweb': [
'static/src/xml/base.xml',
],
'tests': [
],
}

32
sentry_logger/i18n/fr.po

@ -0,0 +1,32 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * sentry_logger
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-10-15 22:09+0000\n"
"PO-Revision-Date: 2014-10-15 18:11-0500\n"
"Last-Translator: Sandy Carter <sandy.carter@savoirfairelinux.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: fr\n"
"X-Generator: Poedit 1.6.9\n"
#. module: sentry_logger
#. openerp-web
#: code:addons/sentry_logger/static/src/xml/base.xml:8
#, python-format
msgid "A detailed report has been sent to the technical support team."
msgstr "Un rapport a été envoyé à l'équipe technique."
#. module: sentry_logger
#. openerp-web
#: code:addons/sentry_logger/static/src/xml/base.xml:7
#, python-format
msgid "An internal OpenERP error has occurred."
msgstr "Une erreur interne à OpenERP est survenue."

30
sentry_logger/i18n/sentry_logger.pot

@ -0,0 +1,30 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * sentry_logger
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-10-15 22:09+0000\n"
"PO-Revision-Date: 2014-10-15 22:09+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: sentry_logger
#. openerp-web
#: code:addons/sentry_logger/static/src/xml/base.xml:8
#, python-format
msgid "A detailed report has been sent to the technical support team."
msgstr ""
#. module: sentry_logger
#. openerp-web
#: code:addons/sentry_logger/static/src/xml/base.xml:7
#, python-format
msgid "An internal OpenERP error has occurred."
msgstr ""

25
sentry_logger/static/src/xml/base.xml

@ -0,0 +1,25 @@
<?xml version = "1.0" encoding="utf-8"?>
<templates>
<t t-extend="CrashManager.error">
<t t-jquery="div.oe_error_detail" t-operation="replace">
<!-- Hide traceback from users -->
<div t-if="session.sentry_activated" class="oe_error_detail">
<h2>An internal OpenERP error has occurred.</h2>
<div class="oe_view_nocontent">
A detailed report has been sent to the technical support team.
</div>
</div>
<!-- Original error message -->
<div t-if="!session.sentry_activated" class="oe_error_detail">
<pre><t t-esc="error.message"/></pre>
<hr/>
<pre><t t-esc="error.data.debug"/></pre>
</div>
</t>
</t>
</templates>
Loading…
Cancel
Save