Skip to content

Commit b640e10

Browse files
Make exceptions concrete
1 parent a711512 commit b640e10

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tools/cadd/cadd.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ def fetch_cadd_score(cadd_version, chromosome, position):
2323
return data
2424
print(f"Error: {response.status_code} - {response.text}")
2525
return None
26-
except Exception as e:
27-
print(f"Error: {e}")
28-
return None
26+
except requests.exceptions.Timeout:
27+
print("Error: Timeout occurred while trying to reach the server.")
28+
except requests.exceptions.RequestException as req_err:
29+
print(f"Error: {req_err}")
30+
except ValueError:
31+
print("Error: Invalid JSON format in response.")
32+
return None
2933

3034
def fetch_cadd_scores(cadd_version, chromosome, start, end):
3135
"""
@@ -47,9 +51,13 @@ def fetch_cadd_scores(cadd_version, chromosome, start, end):
4751
return data
4852
print(f"Error: {response.status_code} - {response.text}")
4953
return None
50-
except Exception as e:
51-
print(f"Error: {e}")
52-
return None
54+
except requests.exceptions.Timeout:
55+
print("Error: Timeout occurred while trying to reach the server.")
56+
except requests.exceptions.RequestException as req_err:
57+
print(f"Error: {req_err}")
58+
except ValueError:
59+
print("Error: Invalid JSON format in response.")
60+
return None
5361

5462
if __name__ == "__main__":
5563
parser = argparse.ArgumentParser(description="Fetch CADD scores for genomic positions.")

0 commit comments

Comments
 (0)