Skip to content

Commit a1f5db9

Browse files
committed
ADD more try-catch to CLI
1 parent 96365ee commit a1f5db9

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

gnomad_api_cli.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,33 @@ def get_variants_by(filter_by, search_term, dataset, timeout=None):
723723
sys.exit("An unknown error occured regarding the internet connection!")
724724

725725
except AttributeError as ae:
726-
pass
726+
# Error Message from gnomAD
727+
try:
728+
for msg in response.json()["errors"]:
729+
sys.exit("Errors from gnomAD for your process:\n\t" + msg["message"])
730+
except Exception as anyOtherException:
731+
pass
732+
733+
if filter_by != "rs_id":
734+
# General Error Message
735+
print("""
736+
It might be caused since the search did not find a result from the database.
737+
Try to check the `input` for `{}` or other `options`.
738+
""".format(filter_by))
739+
740+
# Technical Error Message
741+
print("""
742+
> As a note, technical reason is `{}`.
743+
>
744+
> If you think this should not occur, you can contact with developer to issue this problem on Github page.
745+
""".format(ae))
727746

728747
except (TypeError, KeyError):
729-
for msg in response.json()["errors"]:
730-
sys.exit("Errors from gnomAD for your process:\n\t" + msg["message"])
748+
try:
749+
for msg in response.json()["errors"]:
750+
print("Errors from gnomAD for your process:\n\t" + msg["message"])
751+
except Exception as anyOtherException:
752+
pass
731753

732754
else:
733755
print(" ! DONE: Check out the 'outputs/' folder")

0 commit comments

Comments
 (0)