Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
Make upload errors more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
m-murphy committed Jul 10, 2017
1 parent 40b43ed commit 47d4ecd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/sample-db-py/sample_db/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,16 @@ def update_matrix_tube_locations(self, matrix_tube_entries):
temp_matrix_tube_map[barcode] = matrix_tube_entry['well_position']

comments = matrix_tube_entry.get('comments')
matrix_tube = session.query(MatrixTube).filter(MatrixTube.barcode == barcode).one() # type: MatrixTube
try:
matrix_tube = session.query(MatrixTube).filter(MatrixTube.barcode == barcode).one() # type: MatrixTube
except NoResultFound:
raise NoResultFound('Matrix Tube with barcode {} does not exist.'.format(barcode))
old_plate = matrix_tube.plate

destination_plate = session.query(MatrixPlate).filter(MatrixPlate.uid == plate_uid).one() # type: MatrixPlate
try:
destination_plate = session.query(MatrixPlate).filter(MatrixPlate.uid == plate_uid).one() # type: MatrixPlate
except NoResultFound:
raise NoResultFound('Matrix plate with UID {} does not exist.'.format(plate_uid))
matrix_tube.plate = destination_plate
matrix_tube.well_position = well_position
if comments:
Expand Down
7 changes: 5 additions & 2 deletions src/sample-db-py/sample_db/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,11 @@ def update_plates():
" ['Well', 'Barcode', 'Comments']", status_code=403)
except IntegrityError:
raise InvalidUsage("Tube Position Conflict. Make sure all plates with moved tubes are being updated.", status_code=403)
except NoResultFound:
raise InvalidUsage("One or more plates do not exist", status_code=403)
except NoResultFound as e:
if e.args and e.args[0]:
raise InvalidUsage(e.args[0], status_code=403)
else:
raise InvalidUsage("One or more items do not exist", status_code=403)
except ValueError as e:
raise InvalidUsage(e.args[0], status_code=403)

Expand Down

0 comments on commit 47d4ecd

Please sign in to comment.