Skip to content

Commit fb69a24

Browse files
committed
fix: replace broad common utility exceptions
1 parent 132e503 commit fb69a24

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

biothings/utils/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,12 @@ def anyfile(infile, mode="r"):
222222
except KeyError:
223223
# provided rawfile does not appear in the tarball
224224
tar_file.close()
225-
raise Exception("target member does not contain the provided tar file.")
225+
raise FileNotFoundError("target member does not contain the provided tar file.")
226226

227227
# extracted member is not a regular file or link
228228
if extracted is None:
229229
tar_file.close()
230-
raise Exception("invalid target file: must be a regular file or a link")
230+
raise ValueError("invalid target file: must be a regular file or a link")
231231

232232
return io.TextIOWrapper(extracted)
233233

@@ -807,7 +807,7 @@ def sanitize_tarfile(tar_object, directory):
807807
abs_target = os.path.abspath(target)
808808
prefix = os.path.commonprefix([abs_directory, abs_target])
809809
if not prefix == abs_directory:
810-
raise Exception("Attempted Path Traversal in Tar File")
810+
raise ValueError("Attempted Path Traversal in Tar File")
811811

812812

813813
def sizeof_fmt(num, suffix="B"):

0 commit comments

Comments
 (0)