This repository was archived by the owner on May 31, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
src/sample-db-py/sample_db Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -454,10 +454,16 @@ def update_matrix_tube_locations(self, matrix_tube_entries):
454454 temp_matrix_tube_map [barcode ] = matrix_tube_entry ['well_position' ]
455455
456456 comments = matrix_tube_entry .get ('comments' )
457- matrix_tube = session .query (MatrixTube ).filter (MatrixTube .barcode == barcode ).one () # type: MatrixTube
457+ try :
458+ matrix_tube = session .query (MatrixTube ).filter (MatrixTube .barcode == barcode ).one () # type: MatrixTube
459+ except NoResultFound :
460+ raise NoResultFound ('Matrix Tube with barcode {} does not exist.' .format (barcode ))
458461 old_plate = matrix_tube .plate
459462
460- destination_plate = session .query (MatrixPlate ).filter (MatrixPlate .uid == plate_uid ).one () # type: MatrixPlate
463+ try :
464+ destination_plate = session .query (MatrixPlate ).filter (MatrixPlate .uid == plate_uid ).one () # type: MatrixPlate
465+ except NoResultFound :
466+ raise NoResultFound ('Matrix plate with UID {} does not exist.' .format (plate_uid ))
461467 matrix_tube .plate = destination_plate
462468 matrix_tube .well_position = well_position
463469 if comments :
Original file line number Diff line number Diff line change @@ -475,8 +475,11 @@ def update_plates():
475475 " ['Well', 'Barcode', 'Comments']" , status_code = 403 )
476476 except IntegrityError :
477477 raise InvalidUsage ("Tube Position Conflict. Make sure all plates with moved tubes are being updated." , status_code = 403 )
478- except NoResultFound :
479- raise InvalidUsage ("One or more plates do not exist" , status_code = 403 )
478+ except NoResultFound as e :
479+ if e .args and e .args [0 ]:
480+ raise InvalidUsage (e .args [0 ], status_code = 403 )
481+ else :
482+ raise InvalidUsage ("One or more items do not exist" , status_code = 403 )
480483 except ValueError as e :
481484 raise InvalidUsage (e .args [0 ], status_code = 403 )
482485
You can’t perform that action at this time.
0 commit comments