Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions statechart/models/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@
from sismic.interpreter import Interpreter as SismicInterpreter
from sismic.model import Event

from odoo.exceptions import except_orm


def _root_cause(e):
if isinstance(e, except_orm):
return e
if not hasattr(e, "__cause__") or not e.__cause__:
return e
return _root_cause(e.__cause__)
cause_exc = getattr(e, "__cause__", None)
if cause_exc:
return cause_exc
return e
Comment on lines +12 to +15
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cause_exc = getattr(e, "__cause__", None)
if cause_exc:
return cause_exc
return e
return getattr(e, "__cause__", e)

This could be simplified like this, or even inlined at the two places where this is used, since the _root_cause name does not meany much anymore.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, no. I need more coffee :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather, (e.__cause__ or e), because __cause__ is part of BaseException so getattr should not be necessary anymore.



class Interpreter(SismicInterpreter):
Expand Down