From 3334120a07d8cc7d9ba2e1f23344df4d9c9c33bb Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 12 Feb 2024 18:14:45 +0300 Subject: Provide better error messaging Provide a better error message that can help the user figure out what they did wrong and fix it for themselves instead of the older, cryptic and extremely unhelpful error message. --- scripts/insert_data.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/insert_data.py b/scripts/insert_data.py index 72fc897..a441dcb 100644 --- a/scripts/insert_data.py +++ b/scripts/insert_data.py @@ -253,10 +253,27 @@ def insert_se(# pylint: disable = [too-many-arguments] "VALUES(%(DataId)s, %(StrainId)s, %(DataValue)s)") annotations = annotationinfo(dbconn, platformid, datasetid) if not bool(annotations): - print( - (f"ERROR: No annotations found for platform {platformid} and " - f"dataset {datasetid}. Quiting!"), - file=sys.stderr) + with dbconn.cursor(cursorclass=DictCursor) as cursor: + dquery = cursor.execute(( + "SELECT " + "gc.GeneChipName AS platformname, pf.Name AS studyname, " + "psf.FullName AS datasetname " + "FROM GeneChip AS gc INNER JOIN ProbeFreeze AS pf " + "ON gc.Id=pf.ChipId INNER JOIN ProbeSetFreeze AS psf " + "ON pf.Id=psf.ProbeFreezeId " + "WHERE gc.Id=%s AND psf.Id=%s"), + (platformid, datasetid)) + + errorinfo = dquery.fetchone() + print(("ERROR: No annotations found for the " + f"'{errorinfo['datasetname']}' dataset (Id: {datasetid}) " + f"under the '{errorinfo['studyname']}' study linked to the " + f"'{errorinfo['platformname']}' platform (Id: {platformid})." + "\n\n" + " Please verify you selected the correct platform, " + "study and dataset for the standard-error file(s) you were " + "trying to upload."), + file=sys.stderr) return 1 se_values = ( -- cgit v1.2.3