From 6f004bbf867d22057f98aa7489cd5c1464d59558 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 26 Jan 2025 23:06:13 +0100 Subject: [PATCH] Continued: - raise RuntimeError instead of broad Exception --- fba/commands.py | 6 +++--- fba/helpers/cache.py | 4 ++-- fba/http/csrf.py | 2 +- fba/http/federation.py | 12 ++++++------ fba/http/nodeinfo.py | 4 ++-- fba/models/blocks.py | 30 +++++++++++++++--------------- fba/models/error_log.py | 2 +- fba/models/instances.py | 20 ++++++++++---------- fba/models/obfuscation.py | 6 +++--- fba/networks/friendica.py | 4 ++-- fba/networks/lemmy.py | 10 +++++----- fba/networks/mastodon.py | 8 ++++---- fba/networks/misskey.py | 8 ++++---- fba/networks/peertube.py | 4 ++-- fba/networks/pleroma.py | 8 ++++---- 15 files changed, 64 insertions(+), 64 deletions(-) diff --git a/fba/commands.py b/fba/commands.py index 1bc390e..eaac2f4 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -222,11 +222,11 @@ def fetch_bkali(args: argparse.Namespace) -> int: logger.debug("rows(%d)[]='%s'", len(rows), type(rows)) if len(rows) == 0: - raise Exception("WARNING: Returned no records") + raise RuntimeError("WARNING: Returned no records") elif "data" not in rows: - raise Exception(f"WARNING: rows()={len(rows)} does not contain key 'data'") + raise KeyError(f"WARNING: rows()={len(rows)} does not contain key 'data'") elif "nodeinfo" not in rows["data"]: - raise Exception(f"WARNING: rows()={len(rows['data'])} does not contain key 'nodeinfo'") + raise KeyError(f"WARNING: rows()={len(rows['data'])} does not contain key 'nodeinfo'") for entry in rows["data"]["nodeinfo"]: logger.debug("entry[%s]='%s'", type(entry), entry) diff --git a/fba/helpers/cache.py b/fba/helpers/cache.py index 5d21561..9f538ab 100644 --- a/fba/helpers/cache.py +++ b/fba/helpers/cache.py @@ -59,7 +59,7 @@ def set_sub_key(key: str, sub: str, value: any) -> None: elif not isinstance(sub, str): raise ValueError(f"Parameter sub[]='{type(sub)}' is not of type 'str'") elif not key_exists(key): - raise Exception(f"Cache for key='{key}' is not initialized, but function invoked") + raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked") logger.debug("Setting key='%s',sub='%s',value[%s]='%s' ...", key, sub, type(value), value) _cache[key][sub] = value @@ -74,7 +74,7 @@ def sub_key_exists(key: str, sub: str) -> bool: elif not isinstance(sub, str): raise ValueError(f"Parameter sub[]='{type(sub)}' is not of type 'str'") elif not key_exists(key): - raise Exception(f"Cache for key='{key}' is not initialized, but function invoked") + raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked") exists = sub in _cache[key] diff --git a/fba/http/csrf.py b/fba/http/csrf.py index f9fa0b3..f4da98d 100644 --- a/fba/http/csrf.py +++ b/fba/http/csrf.py @@ -37,7 +37,7 @@ def determine(domain: str, headers: dict) -> dict: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not isinstance(headers, dict): raise ValueError(f"Parameter headers[]='{type(headers)}' is not of type 'dict'") diff --git a/fba/http/federation.py b/fba/http/federation.py index 8839223..5954ae7 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -63,7 +63,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function was invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked") elif not isinstance(origin, str) and origin is not None: raise ValueError(f"Parameter origin[]='{type(origin)}' is not of type 'str'") elif not isinstance(command, str): @@ -225,7 +225,7 @@ def fetch_peers(domain: str, software: str, origin: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function was invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked") elif not isinstance(software, str) and software is not None: raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'") elif isinstance(software, str) and software == "": @@ -293,7 +293,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function was invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked") elif not isinstance(path, str): raise ValueError(f"path[]='{type(path)}' is not of type 'str'") elif path == "": @@ -396,7 +396,7 @@ def determine_software(domain: str, path: str = None) -> str: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function was invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked") elif not isinstance(path, str) and path is not None: raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'") elif path is not None and not path.startswith("/"): @@ -603,9 +603,9 @@ def fetch_blocks(domain: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function was invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") # Init block list blocklist = [] diff --git a/fba/http/nodeinfo.py b/fba/http/nodeinfo.py index e9fb080..1fad0e5 100644 --- a/fba/http/nodeinfo.py +++ b/fba/http/nodeinfo.py @@ -65,7 +65,7 @@ def fetch(domain: str, path: str = None, update_mode: bool = True) -> dict: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function was invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked") elif not isinstance(path, str) and path is not None: raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'") elif path is not None and not path.startswith("/"): @@ -147,7 +147,7 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function was invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked") # No CSRF by default, you don't have to add network.api_headers by yourself here headers = {} diff --git a/fba/models/blocks.py b/fba/models/blocks.py index 0728e59..37ab31d 100644 --- a/fba/models/blocks.py +++ b/fba/models/blocks.py @@ -40,11 +40,11 @@ def get_reason(blocker: str, blocked: str, block_level: str) -> str: elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"block_level='{block_level}' is not wanted.") elif blacklist.is_blacklisted(blocker): - raise Exception(f"blocker='{blocker}' is blacklisted but function invoked") + raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked") elif blacklist.is_blacklisted(blocked): - raise Exception(f"blocked='{blocked}' is blacklisted but function invoked") + raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked") elif not is_instance_blocked(blocker, blocked, block_level): - raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked") + raise RuntimeError(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked") database.cursor.execute( "SELECT reason FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1", @@ -75,11 +75,11 @@ def update_reason(reason: str, blocker: str, blocked: str, block_level: str) -> elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"block_level='{block_level}' is not wanted.") elif blacklist.is_blacklisted(blocker): - raise Exception(f"blocker='{blocker}' is blacklisted but function invoked") + raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked") elif blacklist.is_blacklisted(blocked): - raise Exception(f"blocked='{blocked}' is blacklisted but function invoked") + raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked") elif not is_instance_blocked(blocker, blocked, block_level): - raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked") + raise RuntimeError(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked") logger.debug("Updating block reason='%s',blocker='%s',blocked='%s',block_level='%s'", reason, blocker, blocked, block_level) database.cursor.execute( @@ -106,11 +106,11 @@ def update_last_seen(blocker: str, blocked: str, block_level: str) -> None: elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'") elif blacklist.is_blacklisted(blocker): - raise Exception(f"blocker='{blocker}' is blacklisted but function invoked") + raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked") elif blacklist.is_blacklisted(blocked): - raise Exception(f"blocked='{blocked}' is blacklisted but function invoked") + raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked") elif not is_instance_blocked(blocker, blocked, block_level): - raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked") + raise RuntimeError(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked") database.cursor.execute( "UPDATE blocks SET last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1", @@ -135,9 +135,9 @@ def is_instance_blocked(blocker: str, blocked: str, block_level: str = None) -> elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'") elif blacklist.is_blacklisted(blocker): - raise Exception(f"blocker='{blocker}' is blacklisted but function invoked") + raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked") elif blacklist.is_blacklisted(blocked): - raise Exception(f"blocked='{blocked}' is blacklisted but function invoked") + raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked") if block_level is None: database.cursor.execute( @@ -174,13 +174,13 @@ def add(blocker: str, blocked: str, reason: str, block_level: str) -> None: elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'") elif blacklist.is_blacklisted(blocker): - raise Exception(f"blocker='{blocker}' is blacklisted but function invoked") + raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked") elif blacklist.is_blacklisted(blocked): - raise Exception(f"blocked='{blocked}' is blacklisted but function invoked") + raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked") elif is_instance_blocked(blocker, blocked, block_level): - raise Exception(f"blocker='{blocker}' is already blocking blocked='{blocked}' with block_level='{block_level}' but function was invoked") + raise RuntimeError(f"blocker='{blocker}' is already blocking blocked='{blocked}' with block_level='{block_level}' but function was invoked") elif reason is not None and reason == "": - raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' has empty (not 'None') block reason set") + raise RuntimeError(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' has empty (not 'None') block reason set") logger.debug("reason='%s' - BEFORE!") reason = tidyup.reason(reason) if reason is not None and reason != "" else None diff --git a/fba/models/error_log.py b/fba/models/error_log.py index fca72e6..bbdd94c 100644 --- a/fba/models/error_log.py +++ b/fba/models/error_log.py @@ -37,7 +37,7 @@ def add(domain: str, error: dict) -> None: if blacklist.is_blacklisted(domain): raise ValueError(f"domain='{domain}' is blacklisted but function was invoked") elif not _write_error_log: - raise Exception("Logging of errors is disabled but function was invoked") + raise RuntimeError("Logging of errors is disabled but function was invoked") logger.debug("error[]='%s' - BEFORE!", type(error)) if isinstance(error, (BaseException, json.decoder.JSONDecodeError)): diff --git a/fba/models/instances.py b/fba/models/instances.py index 3bc3d95..3027042 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -95,7 +95,7 @@ def _set_data(key: str, domain: str, value: any) -> None: elif not key in _pending: raise ValueError(f"key='{key}' not found in _pending") elif blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function has been invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked") elif not utils.is_primitive(value): raise ValueError(f"value[]='{type(value)}' is not a primitive type") @@ -111,7 +111,7 @@ def has_pending(domain: str) -> bool: if not is_registered(domain): raise ValueError(f"domain='{domain}' is not registered but function was invoked") elif blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function has been invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked") has = False logger.debug("Checking %d _pending array elements ...", len(_pending)) @@ -130,11 +130,11 @@ def update(domain: str) -> None: domain_helper.raise_on(domain) if not is_registered(domain): - raise Exception(f"domain='{domain}' cannot be updated while not being registered") + raise RuntimeError(f"domain='{domain}' cannot be updated while not being registered") elif not has_pending(domain): - raise Exception(f"domain='{domain}' has no pending instance data, but function invoked") + raise RuntimeError(f"domain='{domain}' has no pending instance data, but function invoked") elif blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function has been invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked") sql_string = "" fields = [] @@ -167,7 +167,7 @@ def update(domain: str) -> None: logger.debug("rowcount=%d", database.cursor.rowcount) if database.cursor.rowcount == 0: - raise Exception(f"Did not update any rows: domain='{domain}',fields()={len(fields)}") + raise RuntimeError(f"Did not update any rows: domain='{domain}',fields()={len(fields)}") logger.debug("Invoking commit() ...") database.connection.commit() @@ -206,11 +206,11 @@ def add(domain: str, origin: str, command: str, path: str = None, software: str elif origin is not None and not validators.domain(origin.split("/")[0], rfc_2782=True): raise ValueError(f"Bad origin name='{origin}'") elif blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted, but function invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted, but function invoked") elif domain.find("/profile/") > 0 or domain.find("/users/") > 0 or (is_registered(domain.split("/")[0]) and domain.find("/c/") > 0): - raise Exception(f"domain='{domain}' is a single user") + raise RuntimeError(f"domain='{domain}' is a single user") elif domain.find("/tag/") > 0: - raise Exception(f"domain='{domain}' is a tag") + raise RuntimeError(f"domain='{domain}' is a tag") if software is None: try: @@ -325,7 +325,7 @@ def is_registered(domain: str, skip_raise: bool = False) -> bool: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function has been invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked") elif not isinstance(skip_raise, bool): raise ValueError(f"skip_raise[]='{type(skip_raise)}' is not type of 'bool'") diff --git a/fba/models/obfuscation.py b/fba/models/obfuscation.py index fcbd363..75f9dee 100644 --- a/fba/models/obfuscation.py +++ b/fba/models/obfuscation.py @@ -48,7 +48,7 @@ def add(pattern: str) -> None: elif pattern == "": raise ValueError("Parametern 'pattern' is an empty string") elif has(pattern): - raise Exception(f"pattern='{pattern}' is already added but function was invoked") + raise RuntimeError(f"pattern='{pattern}' is already added but function was invoked") database.cursor.execute("INSERT INTO obfuscation (pattern, added) VALUES (?, ?)", ( pattern, @@ -64,7 +64,7 @@ def update (pattern: str) -> None: elif pattern == "": raise ValueError("Parametern 'pattern' is an empty string") elif not has(pattern): - raise Exception(f"pattern='{pattern}' is not added but function was invoked") + raise RuntimeError(f"pattern='{pattern}' is not added but function was invoked") database.cursor.execute("UPDATE obfuscation SET last_used=? WHERE pattern=? LIMIT 1", ( time.time(), @@ -80,7 +80,7 @@ def delete (pattern: str) -> None: elif pattern == "": raise ValueError("Parametern 'pattern' is an empty string") elif not has(pattern): - raise Exception(f"pattern='{pattern}' is not added but function was invoked") + raise RuntimeError(f"pattern='{pattern}' is not added but function was invoked") database.cursor.execute("DELETE FROM obfuscation WHERE pattern=? LIMIT 1", [pattern]) diff --git a/fba/networks/friendica.py b/fba/networks/friendica.py index 4d252e1..95356d5 100644 --- a/fba/networks/friendica.py +++ b/fba/networks/friendica.py @@ -35,9 +35,9 @@ def fetch_blocks(domain: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") blocklist = [] block_tag = None diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index 952e27e..5dcbdd5 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -73,9 +73,9 @@ def fetch_peers(domain: str, origin: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") # No CSRF by default, you don't have to add network.api_headers by yourself here @@ -133,9 +133,9 @@ def fetch_blocks(domain: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") blocklist = [] @@ -243,7 +243,7 @@ def fetch_instances(domain: str, origin: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") peers = [] diff --git a/fba/networks/mastodon.py b/fba/networks/mastodon.py index b900ecc..e4e6236 100644 --- a/fba/networks/mastodon.py +++ b/fba/networks/mastodon.py @@ -71,9 +71,9 @@ def fetch_blocks_from_about(domain: str) -> dict: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") # Init variables doc = None @@ -167,9 +167,9 @@ def fetch_blocks(domain: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") # Init variables blocklist = [] diff --git a/fba/networks/misskey.py b/fba/networks/misskey.py index d002333..1f54985 100644 --- a/fba/networks/misskey.py +++ b/fba/networks/misskey.py @@ -37,9 +37,9 @@ def fetch_peers(domain: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") logger.debug("domain='%s' is misskey, sending API POST request ...", domain) peers = [] @@ -136,9 +136,9 @@ def fetch_blocks(domain: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") # No CSRF by default, you don't have to add network.api_headers by yourself here headers = {} diff --git a/fba/networks/peertube.py b/fba/networks/peertube.py index 9af8ebb..ab1aa59 100644 --- a/fba/networks/peertube.py +++ b/fba/networks/peertube.py @@ -33,9 +33,9 @@ def fetch_peers(domain: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") # Init variables peers = [] diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index 3cfa9a6..74fa3b8 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -56,9 +56,9 @@ def fetch_blocks(domain: str) -> list: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") # Init variables blockdict = [] @@ -292,9 +292,9 @@ def fetch_blocks_from_about(domain: str) -> dict: domain_helper.raise_on(domain) if blacklist.is_blacklisted(domain): - raise Exception(f"domain='{domain}' is blacklisted but function is invoked") + raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked") elif not instances.is_registered(domain): - raise Exception(f"domain='{domain}' is not registered but function is invoked") + raise RuntimeError(f"domain='{domain}' is not registered but function is invoked") # Init variables doc = None -- 2.39.5