[FIX] P3: Exception.message removed
This commit is contained in:
@@ -38,7 +38,7 @@ class AuthSignupHome(Home):
|
||||
if request.env["res.users"].sudo().search([("login", "=", qcontext.get("login"))]):
|
||||
qcontext["error"] = _("Another user is already registered using this email address.")
|
||||
else:
|
||||
_logger.error(e.message)
|
||||
_logger.error("%s", e)
|
||||
qcontext['error'] = _("Could not create a new account.")
|
||||
|
||||
return request.render('auth_signup.signup', qcontext)
|
||||
@@ -64,7 +64,7 @@ class AuthSignupHome(Home):
|
||||
qcontext['error'] = _("Could not reset your password")
|
||||
_logger.exception('error when resetting password')
|
||||
except Exception as e:
|
||||
qcontext['error'] = e.message or e.name
|
||||
qcontext['error'] = str(e)
|
||||
|
||||
response = request.render('auth_signup.reset_password', qcontext)
|
||||
response.headers['X-Frame-Options'] = 'DENY'
|
||||
|
||||
@@ -617,9 +617,9 @@ class Import(models.TransientModel):
|
||||
try:
|
||||
line[index] = dt.strftime(dt.strptime(ustr(line[index]).encode('utf-8'), user_format), server_format)
|
||||
except ValueError as e:
|
||||
raise ValueError(_("Column %s contains incorrect values. Error in line %d: %s") % (name, num + 1, ustr(e.message)))
|
||||
raise ValueError(_("Column %s contains incorrect values. Error in line %d: %s") % (name, num + 1, e))
|
||||
except Exception as e:
|
||||
raise ValueError(_("Error Parsing Date [%s:L%d]: %s") % (name, num + 1, ustr(e.message)))
|
||||
raise ValueError(_("Error Parsing Date [%s:L%d]: %s") % (name, num + 1, e))
|
||||
|
||||
elif field['type'] in ('float', 'monetary') and name in import_fields:
|
||||
# Parse float, sometimes float values from file have currency symbol or () to denote a negative value
|
||||
|
||||
@@ -87,7 +87,9 @@ class GoalDefinition(models.Model):
|
||||
# dummy search to make sure the domain is valid
|
||||
Obj.search_count(domain)
|
||||
except (ValueError, SyntaxError) as e:
|
||||
msg = e.message or (e.msg + '\n' + e.text)
|
||||
msg = e
|
||||
if isinstance(e, SyntaxError):
|
||||
msg = (e.msg + '\n' + e.text)
|
||||
raise exceptions.UserError(_("The domain for the definition %s seems incorrect, please check it.\n\n%s") % (definition.name, msg))
|
||||
return True
|
||||
|
||||
@@ -105,7 +107,7 @@ class GoalDefinition(models.Model):
|
||||
_("The model configuration for the definition %s seems incorrect, please check it.\n\n%s not stored") % (definition.name, definition.field_id.name))
|
||||
except KeyError as e:
|
||||
raise exceptions.UserError(
|
||||
_("The model configuration for the definition %s seems incorrect, please check it.\n\n%s not found") % (definition.name, e.message))
|
||||
_("The model configuration for the definition %s seems incorrect, please check it.\n\n%s not found") % (definition.name, e))
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
|
||||
@@ -81,7 +81,7 @@ class EscposDriver(Thread):
|
||||
try:
|
||||
description = usb.util.get_string(printer, 256, printer.iManufacturer) + " " + usb.util.get_string(printer, 256, printer.iProduct)
|
||||
except Exception as e:
|
||||
_logger.error("Can not get printer description: %s" % (e.message or repr(e)))
|
||||
_logger.error("Can not get printer description: %s" % e)
|
||||
description = 'Unknown printer'
|
||||
connected.append({
|
||||
'vendor': printer.idVendor,
|
||||
|
||||
@@ -326,7 +326,7 @@ class MailMail(models.Model):
|
||||
res = IrMailServer.send_email(
|
||||
msg, mail_server_id=mail.mail_server_id.id, smtp_session=smtp_session)
|
||||
except AssertionError as error:
|
||||
if error.message == IrMailServer.NO_VALID_RECIPIENT:
|
||||
if str(error) == IrMailServer.NO_VALID_RECIPIENT:
|
||||
# No valid recipient found for this particular
|
||||
# mail item -> ignore error to avoid blocking
|
||||
# delivery to next recipients, if any. If this is
|
||||
|
||||
@@ -41,7 +41,7 @@ class OgoneController(http.Controller):
|
||||
acq.s2s_process(post)
|
||||
except Exception as e:
|
||||
# synthax error: 'CHECK ERROR: |Not a valid date\n\n50001111: None'
|
||||
error = e.message.splitlines()[0].split('|')[-1] or ''
|
||||
error = str(e).splitlines()[0].split('|')[-1] or ''
|
||||
return werkzeug.utils.redirect(post.get('return_url', '/') + (error and '#error=%s' % werkzeug.url_quote(error) or ''))
|
||||
|
||||
@http.route(['/payment/ogone/s2s/feedback'], auth='none', csrf=False)
|
||||
|
||||
@@ -1053,7 +1053,7 @@ class Binary(http.Controller):
|
||||
args = [len(data), ufile.filename,
|
||||
ufile.content_type, base64.b64encode(data)]
|
||||
except Exception as e:
|
||||
args = [False, e.message]
|
||||
args = [False, str(e)]
|
||||
return out % (json.dumps(callback), json.dumps(args))
|
||||
|
||||
@http.route('/web/binary/upload_attachment', type='http', auth="user")
|
||||
@@ -1647,4 +1647,4 @@ class ReportController(http.Controller):
|
||||
|
||||
@http.route(['/report/check_wkhtmltopdf'], type='json', auth="user")
|
||||
def check_wkhtmltopdf(self):
|
||||
return request.env['ir.actions.report'].get_wkhtmltopdf_state()
|
||||
return request.env['ir.actions.report'].get_wkhtmltopdf_state()
|
||||
|
||||
@@ -319,7 +319,7 @@ class WebsiteSlides(http.Controller):
|
||||
return {'error': e.name}
|
||||
except Exception as e:
|
||||
_logger.error(e)
|
||||
return {'error': _('Internal server error, please try again later or contact administrator.\nHere is the error message: %s') % e.message}
|
||||
return {'error': _('Internal server error, please try again later or contact administrator.\nHere is the error message: %s') % e}
|
||||
return {'url': "/slides/slide/%s" % (slide_id.id)}
|
||||
|
||||
# --------------------------------------------------
|
||||
|
||||
@@ -406,7 +406,7 @@ class IrModelFields(models.Model):
|
||||
try:
|
||||
field = self._related_field()
|
||||
except UserError as e:
|
||||
return {'warning': {'title': _("Warning"), 'message': e.message}}
|
||||
return {'warning': {'title': _("Warning"), 'message': e}}
|
||||
self.ttype = field.type
|
||||
self.relation = field.comodel_name
|
||||
self.readonly = True
|
||||
|
||||
@@ -524,7 +524,7 @@ class JavascriptAsset(WebAsset):
|
||||
try:
|
||||
return super(JavascriptAsset, self)._fetch_content()
|
||||
except AssetError as e:
|
||||
return "console.error(%s);" % json.dumps(e.message)
|
||||
return "console.error(%s);" % json.dumps(str(e))
|
||||
|
||||
def to_html(self):
|
||||
if self.url:
|
||||
@@ -573,7 +573,7 @@ class StylesheetAsset(WebAsset):
|
||||
|
||||
return content
|
||||
except AssetError as e:
|
||||
self.bundle.css_errors.append(e.message)
|
||||
self.bundle.css_errors.append(str(e))
|
||||
return ''
|
||||
|
||||
def minify(self):
|
||||
|
||||
@@ -1200,4 +1200,4 @@ actual arch.
|
||||
try:
|
||||
self.browse(vid)._check_xml()
|
||||
except Exception as e:
|
||||
self.raise_view_error("Can't validate view:\n%s" % (e.message or repr(e)), vid)
|
||||
self.raise_view_error("Can't validate view:\n%s" % e, vid)
|
||||
|
||||
@@ -92,8 +92,6 @@ def ustr(value, hint_encoding='utf-8', errors='strict'):
|
||||
|
||||
|
||||
def exception_to_unicode(e):
|
||||
if (sys.version_info[:2] < (2,6)) and hasattr(e, 'message'):
|
||||
return ustr(e.message)
|
||||
if hasattr(e, 'args'):
|
||||
return "\n".join((ustr(a) for a in e.args))
|
||||
try:
|
||||
|
||||
@@ -85,17 +85,12 @@ def xmlrpc_handle_exception_int(e):
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_APPLICATION_ERROR, formatted_info)
|
||||
response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
|
||||
else:
|
||||
if hasattr(e, 'message') and e.message == 'AccessDenied': # legacy
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_ACCESS_DENIED, str(e))
|
||||
response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
|
||||
#InternalError
|
||||
else:
|
||||
info = sys.exc_info()
|
||||
# Which one is the best ?
|
||||
formatted_info = "".join(traceback.format_exception(*info))
|
||||
#formatted_info = odoo.tools.exception_to_unicode(e) + '\n' + info
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_APPLICATION_ERROR, formatted_info)
|
||||
response = xmlrpclib.dumps(fault, allow_none=None, encoding=None)
|
||||
info = sys.exc_info()
|
||||
# Which one is the best ?
|
||||
formatted_info = "".join(traceback.format_exception(*info))
|
||||
#formatted_info = odoo.tools.exception_to_unicode(e) + '\n' + info
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_APPLICATION_ERROR, formatted_info)
|
||||
response = xmlrpclib.dumps(fault, allow_none=None, encoding=None)
|
||||
return response
|
||||
|
||||
def xmlrpc_handle_exception_string(e):
|
||||
@@ -116,7 +111,7 @@ def xmlrpc_handle_exception_string(e):
|
||||
elif isinstance(e, odoo.exceptions.DeferredException):
|
||||
info = e.traceback
|
||||
formatted_info = "".join(traceback.format_exception(*info))
|
||||
fault = xmlrpclib.Fault(odoo.tools.ustr(e.message), formatted_info)
|
||||
fault = xmlrpclib.Fault(odoo.tools.ustr(e), formatted_info)
|
||||
response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
|
||||
#InternalError
|
||||
else:
|
||||
|
||||
@@ -13,4 +13,4 @@ def check_with_xsd(tree_or_str, xsd_path):
|
||||
except etree.DocumentInvalid as xml_errors:
|
||||
#import UserError only here to avoid circular import statements with tools.func being imported in exceptions.py
|
||||
from odoo.exceptions import UserError
|
||||
raise UserError('\n'.join([e.message for e in xml_errors.error_log]))
|
||||
raise UserError('\n'.join(str(e) for e in xml_errors.error_log))
|
||||
|
||||
Reference in New Issue
Block a user