get rid of ValueError

This commit is contained in:
Jörg Thalheim
2024-09-03 18:07:36 +02:00
parent 403b9cf2cc
commit f18771364c
11 changed files with 34 additions and 22 deletions

View File

@@ -0,0 +1,2 @@
class Error(Exception):
pass

View File

@@ -1,5 +1,7 @@
from urllib.parse import urlparse
from moonlight_sunshine_accept.errors import Error
def parse_moonlight_uri(uri: str) -> tuple[str, int | None]:
print(uri)
@@ -11,10 +13,10 @@ def parse_moonlight_uri(uri: str) -> tuple[str, int | None]:
parsed = urlparse(uri)
if parsed.scheme != "moonlight":
msg = f"Invalid moonlight URI: {uri}"
raise ValueError(msg)
raise Error(msg)
hostname = parsed.hostname
if hostname is None:
msg = f"Invalid moonlight URI: {uri}"
raise ValueError
raise Error(msg)
port = parsed.port
return (hostname, port)