Use raise from instead of logging

issue10146
review357301002
This commit is contained in:
Cédric Krier
2021-03-11 19:07:33 +01:00
parent 674b469b45
commit 45775dbf15
2 changed files with 2 additions and 13 deletions
+2 -5
View File
@@ -455,11 +455,8 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
try:
self.sax_parser.parse(source)
except Exception:
logger.error(
"Error while parsing xml file:\n" + self.current_state(),
exc_info=True)
raise
except Exception as e:
raise Exception("Error " + self.current_state()) from e
return self.to_delete
def startElement(self, name, attributes):
-8
View File
@@ -1,7 +1,6 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import os
import logging
import json
from lxml import etree
@@ -17,8 +16,6 @@ from trytond.pool import Pool
from trytond.cache import Cache
from trytond.rpc import RPC
logger = logging.getLogger(__name__)
class XMLError(ValidationError):
pass
@@ -137,8 +134,6 @@ class View(ModelSQL, ModelView):
if not validator.validate(tree):
error_log = '\n'.join(map(str,
validator.error_log.filter_from_errors()))
logger.error('Invalid XML view %s:\n%s\n%s',
view.rec_name, error_log, xml)
raise XMLError(
gettext('ir.msg_view_invalid_xml', name=view.rec_name),
error_log)
@@ -160,9 +155,6 @@ class View(ModelSQL, ModelView):
error_log = '%s: <%s %s="%s"/>' % (
e, element.get('id') or element.get('name'), attr,
element.get(attr))
logger.error(
'Invalid XML view %s:\n%s\n%s',
view.rec_name, error_log, xml)
raise XMLError(
gettext(
'ir.msg_view_invalid_xml', name=view.rec_name),