From 2e010fea0c7a0ed00e5208ce341ed56a5d5f472b Mon Sep 17 00:00:00 2001 From: Derek Maggio Date: Thu, 30 May 2024 09:31:46 -0700 Subject: [PATCH] fix: underlying function exception was not being raised --- .../src/performance_metrics/robot_context_tracker.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/performance-metrics/src/performance_metrics/robot_context_tracker.py b/performance-metrics/src/performance_metrics/robot_context_tracker.py index 23d3b2b3c16..a9956433b1f 100644 --- a/performance-metrics/src/performance_metrics/robot_context_tracker.py +++ b/performance-metrics/src/performance_metrics/robot_context_tracker.py @@ -84,11 +84,15 @@ async def track(self, func_to_track: Callable, state: RobotContextState, *args, if inspect.iscoroutinefunction(func_to_track): try: result = await func_to_track(*args, **kwargs) + except Exception as e: + result = e finally: duration_end_time = perf_counter_ns() else: try: result = func_to_track(*args, **kwargs) + except Exception as e: + result = e finally: duration_end_time = perf_counter_ns() @@ -99,7 +103,11 @@ async def track(self, func_to_track: Callable, state: RobotContextState, *args, state=state, ) ) - return result + + if isinstance(result, Exception): + raise result + else: + return result