2121from olive .systems .common import SystemType
2222from olive .telemetry .constants import SUPPRESS_WORKFLOW_TELEMETRY_ENV
2323from olive .telemetry .telemetry import is_ci_environment
24- from olive .telemetry .telemetry_extensions import log_recipe_result
24+ from olive .telemetry .telemetry_extensions import _format_exception_message , log_error , log_recipe_result
2525from olive .workflows .run .config import RunConfig
2626
2727if TYPE_CHECKING :
@@ -213,7 +213,7 @@ def run(
213213
214214 parsed_run_config = None
215215 success = False
216- exception_type = None
216+ exception = None
217217 try :
218218 package_config = OlivePackageConfig .parse_file_or_obj (package_config )
219219 parsed_run_config = RunConfig .parse_file_or_obj (run_config )
@@ -238,9 +238,14 @@ def run(
238238 success = True
239239 return workflow_output
240240 except Exception as exc :
241- exception_type = type ( exc ). __name__
241+ exception = exc
242242 raise
243243 finally :
244+ if exception is not None :
245+ log_error (
246+ exception_type = type (exception ).__name__ ,
247+ exception_message = _format_exception_message (exception , exception .__traceback__ ),
248+ )
244249 if os .environ .get (SUPPRESS_WORKFLOW_TELEMETRY_ENV ) != "1" :
245250 metadata = _build_recipe_result_metadata (
246251 run_config ,
@@ -252,7 +257,7 @@ def run(
252257 package_config_provided = package_config_provided ,
253258 )
254259 recipe_name = metadata .pop ("recipe_name" )
255- log_recipe_result (recipe_name , success = success , metadata = metadata , exception_type = exception_type )
260+ log_recipe_result (recipe_name , success = success , metadata = metadata )
256261
257262
258263def generate_files_from_packages (packages , file_name ):
0 commit comments