chore: raise from specific exceptions
This commit is contained in:
parent
284fd5c688
commit
f8f6fda794
|
@ -1,6 +1,6 @@
|
|||
from typing import Callable, Optional
|
||||
|
||||
from django.db import connection
|
||||
from django.db import DataError, connection
|
||||
|
||||
from ._version import parse_version
|
||||
|
||||
|
@ -53,7 +53,7 @@ def legacy_migration_factory(
|
|||
def inner(_apps, _schema_editor):
|
||||
current = get_schema_version()
|
||||
if current is None:
|
||||
raise Exception("current schema version was not found!")
|
||||
raise DataError("current schema version was not found!")
|
||||
|
||||
current_version = parse_version(current)
|
||||
if current_version >= target_version and not reverse:
|
||||
|
|
|
@ -21,7 +21,7 @@ VERSION_RE = re.compile(
|
|||
def parse_version(version: str):
|
||||
match = VERSION_RE.search(version)
|
||||
if not match:
|
||||
raise Exception(f"invalid version {version}")
|
||||
raise ValueError(f"invalid version {version}")
|
||||
|
||||
release = list(map(int, match.group("release").split(".")))
|
||||
major = release.pop(0) if release else 0
|
||||
|
|
|
@ -83,7 +83,7 @@ def cli(log_level: str, log_filepath: Optional[Path], config_filepath: Optional[
|
|||
logger.debug("Checking if Liquidsoap is running")
|
||||
liq_version = liq_client.wait_for_version()
|
||||
if not LIQUIDSOAP_MIN_VERSION <= liq_version:
|
||||
raise Exception(f"Invalid liquidsoap version {liq_version}")
|
||||
raise RuntimeError(f"Invalid liquidsoap version {liq_version}")
|
||||
|
||||
fetch_queue: Queue[Dict[str, Any]] = Queue()
|
||||
recorder_queue: Queue[Dict[str, Any]] = Queue()
|
||||
|
|
|
@ -65,7 +65,7 @@ class PypoFile(Thread):
|
|||
handle.write(chunk)
|
||||
|
||||
except HTTPError as exception:
|
||||
raise Exception(
|
||||
raise RuntimeError(
|
||||
f"could not download file {media_item['id']}"
|
||||
) from exception
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ def __timeout(func, timeout_duration, default, args, kwargs):
|
|||
thread.join(timeout_duration)
|
||||
|
||||
if thread.is_alive():
|
||||
raise Exception("Thread did not terminate")
|
||||
raise RuntimeError("Thread did not terminate")
|
||||
|
||||
return thread.result
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ def list_packages_files(
|
|||
path = path / DEFAULT_PACKAGES_FILENAME
|
||||
|
||||
if not path.is_file():
|
||||
raise Exception(f"{path} is not a file!")
|
||||
raise ValueError(f"{path} is not a file!")
|
||||
|
||||
yield path
|
||||
|
||||
|
|
Loading…
Reference in New Issue