]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 22:06:13 +0000 (23:06 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 22:06:13 +0000 (23:06 +0100)
- raise RuntimeError instead of broad Exception

15 files changed:
fba/commands.py
fba/helpers/cache.py
fba/http/csrf.py
fba/http/federation.py
fba/http/nodeinfo.py
fba/models/blocks.py
fba/models/error_log.py
fba/models/instances.py
fba/models/obfuscation.py
fba/networks/friendica.py
fba/networks/lemmy.py
fba/networks/mastodon.py
fba/networks/misskey.py
fba/networks/peertube.py
fba/networks/pleroma.py

index 1bc390e402e4dc54d8dce9a964f3190bf7ed8b48..eaac2f4e36620e22f803625143abcf687c854e35 100644 (file)
@@ -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)
index 5d2156102a077dca6c485cb5b918b7bbd553a344..9f538abda0cdd11e2d9717bf582adb2e75e37a26 100644 (file)
@@ -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]
 
index f9fa0b3430c9346d0a7ee6e1b0652247d7332f82..f4da98d3506734ed4182c6143ce94ec7575039b6 100644 (file)
@@ -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'")
 
index 8839223a76cdea9b31fd2c88735a4fa87427e4cd..5954ae73257b88573d99f1a877628cffeed13e48 100644 (file)
@@ -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 = []
index e9fb0808ac9285021d89a3953c12fd26fe47fd36..1fad0e5a38371cea53bdfeba7564fa6d78ba0eac 100644 (file)
@@ -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 = {}
index 0728e599bcf7a5bc5bf002d2fb0f5ee1ac4e4866..37ab31dfd1de4c47fba0fa989d99ac0c17a13ec3 100644 (file)
@@ -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
index fca72e6ac9551da96d71a513cc3a2421eafc4c97..bbdd94c460ee63f342a890e019339f92f361c34a 100644 (file)
@@ -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)):
index 3bc3d958a5080e3f3d14aad88229244b6993cd73..3027042e4f0d9b54c5edc740997be0be366b2b8e 100644 (file)
@@ -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'")
 
index fcbd36362b89ad33f3d1bd31407db165ba98a3f8..75f9deec4d081839d9c509954d3d1d63cf2fa340 100644 (file)
@@ -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])
 
index 4d252e114c566a81329bc073708c944091019057..95356d5c334dd75be070e0bb04dadf70a86b1714 100644 (file)
@@ -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
index 952e27eb4b2a9b6f27997f56abb82c7e31a61a97..5dcbdd510ca265d6b72848e0fb3184cef38d0ac3 100644 (file)
@@ -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 = []
 
index b900eccd111b28afb176e90906df381c2393fd95..e4e62366577ef5fb8ef97872389a703730b3420c 100644 (file)
@@ -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 = []
index d00233357a04eb118e3564e98a13aaaa8652c592..1f5498564fa7d5e3ebcd6b030e4d1dd1fdd64042 100644 (file)
@@ -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 = {}
index 9af8ebbb484a3f503992efc841b82aac1a491f4d..ab1aa596c8a1047e792d355435fdb6c1cef5f61e 100644 (file)
@@ -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   = []
index 3cfa9a632e89f153ca49d840bb55aaf374f70593..74fa3b88a80382842ebc2824d50bf1e41767169e 100644 (file)
@@ -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