From 6c308016bf354c6f6e6dddc6d580e524fce2b91e Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 5 Apr 2024 13:51:29 +0300 Subject: Handle exceptions creating ProbeSet datasets. --- qc_app/upload/rqtl2.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'qc_app/upload/rqtl2.py') diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index 7a53756..60aeba7 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -656,14 +656,27 @@ def create_probeset_dataset(species_id: int, population_id: int):#pylint: disabl flash("Invalid averaging method provided!", "alert-error error-rqtl2") return summary_page - dset = probeset_create_dataset(conn, - int(form["probe-study-id"]), - int(form["averageid"]), - form["datasetname"], - form["datasetfullname"], - form["datasetshortname"], - form["datasetpublic"] == "on", - form.get("datasetdatascale", "log2")) + try: + dset = probeset_create_dataset(conn, + int(form["probe-study-id"]), + int(form["averageid"]), + form["datasetname"], + form["datasetfullname"], + form["datasetshortname"], + form["datasetpublic"] == "on", + form.get( + "datasetdatascale", "log2")) + except mdb.IntegrityError as _ierr: + flash(("A dataset with that name already exists. Try selecting " + "from list of datasets instead."), + "alert-error error-rqtl2") + return summary_page + except Exception as _exc: + app.logger.debug("Error creating ProbeSet dataset: %s", + traceback.format_exc()) + flash(("There was a problem creating your dataset. Please try " + "again."), + "alert-error error-rqtl2") return render_template( "rqtl2/create-probe-dataset-success.html", species=species_by_id(conn, species_id), -- cgit v1.2.3