aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/tools.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-19 07:26:53 +0300
committerFrederick Muriuki Muriithi2022-09-19 07:47:37 +0300
commit50774454e1424c719b082e8b704296f47a7e0f7d (patch)
tree16c766c15469c1eddc1669ce3c19ba7bc10c87ca /wqflask/utility/tools.py
parentb85b886f3dacce3aa2756d3a64a2cb8890ad1eb3 (diff)
downloadgenenetwork2-50774454e1424c719b082e8b704296f47a7e0f7d.tar.gz
Refactor: raise appropriate error
If a file/directory does not exist, raise the builtin `FileNotFoundError` rather than the generic `Exception`.
Diffstat (limited to 'wqflask/utility/tools.py')
-rw-r--r--wqflask/utility/tools.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index 19bf686b..fe059015 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -152,10 +152,10 @@ def assert_bin(fn):
return fn
-def assert_dir(dir):
- if not valid_path(dir):
- raise Exception("ERROR: can not find directory " + dir)
- return dir
+def assert_dir(the_dir):
+ if not valid_path(the_dir):
+ raise FileNotFoundError(f"ERROR: can not find directory '{the_dir}'")
+ return the_dir
def assert_writable_dir(dir):
@@ -172,7 +172,7 @@ def assert_writable_dir(dir):
def assert_file(fn):
if not valid_file(fn):
- raise Exception('Unable to find file ' + fn)
+ raise FileNotFoundError(f"Unable to find file '{fn}'")
return fn