lib: fix stacktrace for general expressions
This commit is contained in:
parent
1a619c90de
commit
e555bdd42b
|
@ -98,6 +98,10 @@ class BaseEvaluator:
|
|||
exec(ast_obj, self._globals, _locals) # nosec # noqa
|
||||
result = _locals["result"]
|
||||
except Exception as exc:
|
||||
# So, this is a bit questionable. Essentially, we are edit the stacktrace
|
||||
# so the user only sees information relevant to them
|
||||
# and none of our surrounding error handling
|
||||
exc.__traceback__ = exc.__traceback__.tb_next
|
||||
self.handle_error(exc, expression_source)
|
||||
raise exc
|
||||
return result
|
||||
|
|
|
@ -55,10 +55,6 @@ class PolicyEvaluator(BaseEvaluator):
|
|||
|
||||
def handle_error(self, exc: Exception, expression_source: str):
|
||||
"""Exception Handler"""
|
||||
# So, this is a bit questionable. Essentially, we are edit the stacktrace
|
||||
# so the user only sees information relevant to them
|
||||
# and none of our surrounding error handling
|
||||
exc.__traceback__ = exc.__traceback__.tb_next
|
||||
raise PolicyException(exc)
|
||||
|
||||
def evaluate(self, expression_source: str) -> PolicyResult:
|
||||
|
|
Reference in New Issue