@@ -1455,7 +1455,12 @@ def get_all_calibrations_as_yamls(pioreactor_unit: str) -> ResponseReturnValue:
14551455 try :
14561456 results = task .get (blocking = True , timeout = 60 )
14571457 except (HueyException , TaskException ):
1458- return {"result" : False , "filename" : None , "msg" : "Timed out" }, 500
1458+ abort_with (
1459+ 500 ,
1460+ "Timed out fetching calibrations" ,
1461+ cause = "Timed out waiting for workers to provide calibration archives." ,
1462+ remediation = "Retry the request and check worker connectivity." ,
1463+ )
14591464
14601465 aggregate_buffer = BytesIO ()
14611466
@@ -1507,7 +1512,12 @@ def get_entire_dot_pioreactor(pioreactor_unit: str) -> ResponseReturnValue:
15071512 try :
15081513 results = task .get (blocking = True , timeout = 120 )
15091514 except (HueyException , TaskException ):
1510- return {"result" : False , "filename" : None , "msg" : "Timed out" }, 500
1515+ abort_with (
1516+ 500 ,
1517+ "Timed out fetching .pioreactor archive" ,
1518+ cause = "Timed out waiting for worker responses." ,
1519+ remediation = "Retry the request and check worker connectivity." ,
1520+ )
15111521
15121522 # If only one worker, proxy its ZIP directly
15131523 if isinstance (results , dict ) and len (results ) == 1 :
@@ -2223,12 +2233,21 @@ def export_datasets() -> ResponseReturnValue:
22232233 try :
22242234 status , msg = result (blocking = True , timeout = 5 * 60 )
22252235 except (HueyException , TaskException ):
2226- status = False
2227- return {"result" : status , "filename" : None , "msg" : "Task error, or time out" }, 500
2236+ abort_with (
2237+ 500 ,
2238+ "Export task failed or timed out" ,
2239+ cause = "Task error or timeout while exporting datasets." ,
2240+ remediation = "Retry the export and check server logs if it persists." ,
2241+ )
22282242
22292243 if not status :
22302244 publish_to_error_log (msg , "export_datasets" )
2231- return {"result" : status , "filename" : None , "msg" : msg }, 500
2245+ abort_with (
2246+ 500 ,
2247+ "Export task failed" ,
2248+ cause = msg ,
2249+ remediation = "Check server logs for details and retry the export." ,
2250+ )
22322251
22332252 return {"result" : status , "filename" : filename , "msg" : "Finished" }, 200
22342253
@@ -2323,7 +2342,12 @@ def create_experiment() -> ResponseReturnValue:
23232342 return {"status" : "success" }, 201
23242343
23252344 except sqlite3 .IntegrityError :
2326- return {"status" : "error" }, 409
2345+ abort_with (
2346+ 409 ,
2347+ "Experiment already exists" ,
2348+ cause = "Experiment name conflicts with an existing experiment." ,
2349+ remediation = "Choose a different experiment name and retry." ,
2350+ )
23272351 except Exception as e :
23282352 publish_to_error_log (str (e ), "create_experiment" )
23292353 abort_with (500 , str (e ))
@@ -3287,7 +3311,7 @@ def get_experiment_assignment_for_worker(pioreactor_unit: str) -> ResponseReturn
32873311 if result is None :
32883312 abort_with (
32893313 404 ,
3290- f"Worker { pioreactor_unit } does not exist in the cluster ." ,
3314+ f"Worker { pioreactor_unit } not found ." ,
32913315 cause = f"Worker '{ pioreactor_unit } ' not in leader database." ,
32923316 remediation = "Check the unit name or add the worker to the inventory." ,
32933317 )
0 commit comments