From 4c077c01db19e8adc01d9559677ad5693a1db909 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 9 Feb 2024 04:22:51 +0300 Subject: Raise error if file is missing rather than returning a Union value. --- qc_app/samples.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'qc_app/samples.py') diff --git a/qc_app/samples.py b/qc_app/samples.py index 55e94ab..1845818 100644 --- a/qc_app/samples.py +++ b/qc_app/samples.py @@ -219,9 +219,12 @@ def upload_samples(): flash("Invalid grouping/population!", "alert-error") return samples_uploads_page - samples_file = save_file(request.files["samples_file"], Path(app.config["UPLOAD_FOLDER"])) - if not bool(samples_file): - flash("You need to provide a file with the samples data.") + try: + samples_file = save_file(request.files["samples_file"], + Path(app.config["UPLOAD_FOLDER"])) + except AssertionError: + flash("You need to provide a file with the samples data.", + "alert-error") return samples_uploads_page firstlineheading = (request.form.get("first_line_heading") == "on") -- cgit v1.2.3