From 7b35ea3c2107e53dac43a11b67ae3961fe74b29f Mon Sep 17 00:00:00 2001 From: Neeraj Tickoo Date: Mon, 18 Nov 2024 12:21:17 -0600 Subject: [PATCH] Add stacktrace to exception message. --- rpe/engines/python.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rpe/engines/python.py b/rpe/engines/python.py index 81e6867..122064e 100644 --- a/rpe/engines/python.py +++ b/rpe/engines/python.py @@ -16,6 +16,7 @@ import importlib.util import inspect import sys +import traceback from dataclasses import asdict @@ -114,8 +115,9 @@ def evaluate(self, resource): # These are user-provided modules, we need to catch any exception except Exception as e: - print(f"Evaluation exception. Policy: {policy_name}, Message: {str(e)}") - + print("Evaluation exception. Policy: {0}, Message: {1}, Exception Stacktrace: {2}".format( + policy_name, repr(e), traceback.format_exc() + )) return evals def _legacy_eval(self, resource, policy_name, policy_cls):