@@ -351,10 +351,13 @@ def export_data(
351351 filename = export_plugin .generate_filename (
352352 serializer_class .Meta .model , export_format
353353 )
354- except Exception :
354+ except Exception as e :
355355 InvenTree .exceptions .log_error (
356356 'generate_filename' , plugin = export_plugin .slug
357357 )
358+
359+ output .mark_failure (error = str (e ))
360+
358361 raise ValidationError (export_error )
359362
360363 # The provided plugin is responsible for exporting the data
@@ -364,8 +367,12 @@ def export_data(
364367 queryset , serializer_class , headers , export_context , output
365368 )
366369
367- except Exception :
370+ except Exception as e :
368371 InvenTree .exceptions .log_error ('export_data' , plugin = export_plugin .slug )
372+
373+ # Log the error against the output object
374+ output .mark_failure (error = str (e ))
375+
369376 raise ValidationError (export_error )
370377
371378 if not isinstance (data , list ):
@@ -377,17 +384,21 @@ def export_data(
377384 if hasattr (export_plugin , 'update_headers' ):
378385 try :
379386 headers = export_plugin .update_headers (headers , export_context )
380- except Exception :
387+ except Exception as e :
381388 InvenTree .exceptions .log_error (
382389 'update_headers' , plugin = export_plugin .slug
383390 )
391+
392+ output .mark_failure (error = str (e ))
393+
384394 raise ValidationError (export_error )
385395
386396 # Now, export the data to file
387397 try :
388398 datafile = serializer .export_to_file (data , headers , export_format )
389- except Exception :
399+ except Exception as e :
390400 InvenTree .exceptions .log_error ('export_to_file' , plugin = export_plugin .slug )
401+ output .mark_failure (error = str (e ))
391402 raise ValidationError (_ ('Error occurred during data export' ))
392403
393404 # Update the output object with the exported data
0 commit comments