Skip to content

Commit

Permalink
Raise a more specific exception
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Sep 5, 2024
1 parent 1d3b8c8 commit 0e075b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tap_csv/file_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
from singer_sdk.streams import Stream


class FileStreamError(Exception):
"""Exception for file stream errors."""


class FileStream(Stream, metaclass=abc.ABCMeta):
"""Abstract class for file streams."""

Expand Down Expand Up @@ -47,7 +51,7 @@ def get_file_paths(self) -> list[str]:
file_path = self.file_config["path"]
if not self.fs.exists(file_path):
errmsg = f"File path does not exist {file_path}"
raise Exception(errmsg)
raise FileStreamError(errmsg)

file_paths = []
if self.fs.isdir(file_path):
Expand All @@ -59,7 +63,7 @@ def get_file_paths(self) -> list[str]:

if not file_paths:
msg = f"Stream '{self.name}' has no acceptable files"
raise RuntimeError(msg)
raise FileStreamError(msg)

self._file_paths = file_paths

Expand Down

0 comments on commit 0e075b1

Please sign in to comment.