Skip to content

Commit

Permalink
[FIX] core: log unexpected validation exceptions
Browse files Browse the repository at this point in the history
Before this patch, any exception raised by a constraint method that
were not of type `ValidationError` were hard to debug, because the
origin line was never logged.

Explicitly logging the error (with traceback) when we catch it
ensures proper contextual info, even in the absence of exception
chaining.

closes #28612
  • Loading branch information
yajo authored and odony committed Feb 20, 2019
1 parent 6cf4f49 commit 2b1d3ff
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions odoo/models.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ def _validate_fields(self, field_names):
except ValidationError, e: except ValidationError, e:
raise raise
except Exception, e: except Exception, e:
_logger.exception('Exception while validating constraint')
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e))) raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))


@api.model @api.model
Expand Down

0 comments on commit 2b1d3ff

Please sign in to comment.