fix(core): cut user-facing errors and warnings to one line

This commit is contained in:
imSp4rky
2026-10-23 20:23:05 -06:00
parent dfc99783b5
commit 83514d12fe
45 changed files with 210 additions and 415 deletions
+15 -29
View File
@@ -191,10 +191,7 @@ class Gluetun(Proxy):
verify_ip: Automatically make sure that the IP and region are correct after connection (default: True)
"""
if not binaries.Docker:
raise RuntimeError(
"Docker is not available. Please install Docker to use Gluetun proxy.\n"
"Visit: https://docs.docker.com/engine/install/"
)
raise RuntimeError("Docker not found, the Gluetun proxy needs it")
self.providers = providers or {}
self.base_port = base_port
@@ -247,14 +244,14 @@ class Gluetun(Proxy):
if len(parts) == 1:
return None
if len(parts) != 2:
raise ValueError(f"Invalid query format: '{query}'. Expected 'provider:region' (e.g., 'windscribe:us')")
raise ValueError(f"Invalid query '{query}': expected provider:region, such as windscribe:us")
provider_name = parts[0].lower()
region = parts[1].lower()
if provider_name not in self.providers:
available = ", ".join(self.providers.keys())
raise ValueError(f"VPN provider '{provider_name}' not configured. Available providers: {available}")
raise ValueError(f"VPN provider '{provider_name}' not configured, available: {available}")
query_key = f"{provider_name}:{region}"
container_name = f"{self.container_prefix}-{provider_name}-{region}"
@@ -320,15 +317,9 @@ class Gluetun(Proxy):
if re.match(r"^[a-z]{2}$", region):
country = get_country_name(region)
if not country:
raise ValueError(
f"Country code '{region}' not recognized. "
f"Configure it in server_countries or use a valid ISO 3166-1 alpha-2 code."
)
raise ValueError(f"Country code '{region}' not recognized")
else:
raise ValueError(
f"Region '{region}' not recognized for provider '{provider_name}'. "
f"Configure it in server_countries or server_cities, or use a 2-letter country code."
)
raise ValueError(f"Region '{region}' not recognized for provider '{provider_name}'")
self.remove_stopped_container(container_name)
@@ -453,7 +444,7 @@ class Gluetun(Proxy):
credentials = config.get("credentials", {})
if vpn_type not in ["wireguard", "openvpn"]:
raise ValueError(f"Provider '{provider_name}': Invalid vpn_type '{vpn_type}'. Use 'wireguard' or 'openvpn'")
raise ValueError(f"Provider '{provider_name}': vpn_type '{vpn_type}' is not wireguard or openvpn")
if vpn_type == "wireguard":
# private_key is always required for WireGuard
@@ -468,16 +459,11 @@ class Gluetun(Proxy):
# Windscribe requires preshared_key (can be empty string, but must be set)
if provider_lower == "windscribe":
if "preshared_key" not in credentials:
raise ValueError(
f"Provider '{provider_name}': Windscribe WireGuard requires 'preshared_key' in credentials "
"(can be empty string, but must be set). Get it from windscribe.com/getconfig/wireguard"
)
if "addresses" not in credentials:
raise ValueError(
f"Provider '{provider_name}': Windscribe WireGuard requires 'addresses' in credentials. "
"Get it from windscribe.com/getconfig/wireguard"
)
for key in ("preshared_key", "addresses"):
if key not in credentials:
raise ValueError(
f"Provider '{provider_name}': Windscribe WireGuard needs '{key}' in credentials"
)
# Providers that require addresses (but not preshared_key)
elif provider_lower in ["surfshark", "mullvad", "ivpn"]:
@@ -539,8 +525,8 @@ class Gluetun(Proxy):
country_lower = country_code.lower()
if provider_name == "surfshark":
raise ValueError(
"Surfshark has no numbered servers. Map the region to a server name such as "
f"'{country_lower}-dal.prod.surfshark.com' in server_hostnames instead."
f"Surfshark has no numbered servers: map the region in server_hostnames, "
f"such as '{country_lower}-dal.prod.surfshark.com'"
)
hostname_formats = {
"nordvpn": f"{country_lower}{server_num}.nordvpn.com",
@@ -646,7 +632,7 @@ class Gluetun(Proxy):
message=f"Failed to pull Docker image: {gluetun_image}",
success=False,
)
raise RuntimeError(f"Failed to ensure Gluetun Docker image '{gluetun_image}' is available")
raise RuntimeError(f"Failed to pull the Gluetun proxy Docker image '{gluetun_image}'")
vpn_type = provider_config.get("vpn_type", "wireguard").lower()
credentials = provider_config.get("credentials", {})
@@ -1234,7 +1220,7 @@ class Gluetun(Proxy):
)
raise RuntimeError(
f"Failed to verify VPN IP for {container['provider']}:{container['region']} "
f"after {max_retries} attempts. Last error: {last_error}"
f"after {max_retries} attempts: {last_error}"
)
def remove_stopped_container(self, container_name: str) -> bool:
+1 -1
View File
@@ -37,7 +37,7 @@ class Hola(Proxy):
return None
ban = "Transaction error: temporary ban detected."
banned = ConnectionError("Hola banned your IP temporarily from it's services. Try change your IP.")
banned = ConnectionError("Hola temporarily banned your IP")
try:
# hola-proxy logs to stderr from another thread, so a merged stream splits the Login/Password lines.
result = subprocess.run(
+4 -10
View File
@@ -19,14 +19,11 @@ class NordVPN(Proxy):
The Service Credentials can be found here: https://my.nordaccount.com/dashboard/nordvpn/
"""
if not username:
raise ValueError("No Username was provided to the NordVPN Proxy Service.")
raise ValueError("No username for the NordVPN proxy provider")
if not password:
raise ValueError("No Password was provided to the NordVPN Proxy Service.")
raise ValueError("No password for the NordVPN proxy provider")
if not re.match(r"^[a-z0-9]{48}$", username + password, re.IGNORECASE) or "@" in username:
raise ValueError(
"The Username and Password must be NordVPN Service Credentials, not your Login Credentials. "
"The Service Credentials can be found here: https://my.nordaccount.com/dashboard/nordvpn/"
)
raise ValueError("NordVPN needs its Service Credentials, not your login credentials")
if server_map is not None and not isinstance(server_map, dict):
raise TypeError(f"Expected server_map to be a dict mapping a region to a server ID, not '{server_map!r}'.")
@@ -101,10 +98,7 @@ class NordVPN(Proxy):
None,
)
if city_id is None:
raise ValueError(
f"No servers found in city '{city}' for country '{country['name']}'. "
"Try a different city or check the city name spelling."
)
raise ValueError(f"No servers found in city '{city}' for country '{country['name']}'")
if selector and is_ip(selector):
recommended_servers = self.get_all_servers(country["id"])
else:
+1 -2
View File
@@ -226,8 +226,7 @@ class ProtonVPN(Proxy):
self.load_session()
if not self.access_token:
log.error(
"Proton: no session available; export account.proton.me cookies to %s "
"or set proxy_providers.protonvpn.enable: true for the one-time TV login",
"Proton: no access token, export account.proton.me cookies to %s or set proxy_providers.protonvpn.enable",
self.cookie_path,
)
return None
+1 -1
View File
@@ -127,7 +127,7 @@ def initialize_proxy_providers(raise_errors: bool = False, quiet: bool = False)
"""
proxy_providers = load_proxy_providers(("gluetun",), raise_errors, quiet)
if not quiet and not proxy_providers:
log.warning("No proxy providers were loaded. Check your proxy provider configuration in unshackle.yaml")
log.warning("No proxy providers were loaded")
return proxy_providers
+5 -11
View File
@@ -91,14 +91,11 @@ class SurfsharkVPN(Proxy):
The Service Credentials can be found here: https://my.surfshark.com/vpn/manual-setup/main/openvpn
"""
if not username:
raise ValueError("No Username was provided to the SurfsharkVPN Proxy Service.")
raise ValueError("No username for the SurfsharkVPN proxy provider")
if not password:
raise ValueError("No Password was provided to the SurfsharkVPN Proxy Service.")
raise ValueError("No password for the SurfsharkVPN proxy provider")
if not re.match(r"^[a-z0-9]{48}$", username + password, re.IGNORECASE) or "@" in username:
raise ValueError(
"The Username and Password must be SurfsharkVPN Service Credentials, not your Login Credentials. "
"The Service Credentials can be found here: https://my.surfshark.com/vpn/manual-setup/main/openvpn"
)
raise ValueError("SurfsharkVPN needs its Service Credentials, not your login credentials")
if server_map is not None and not isinstance(server_map, dict):
raise TypeError(
@@ -113,8 +110,7 @@ class SurfsharkVPN(Proxy):
if not server or server.isdigit():
# A warning, not an error: one stale entry must not disable the whole proxy provider.
log.warning(
"SurfsharkVPN: ignoring server_map entry '%s: %s'. Use a server name such as 'us-dal'. "
"SurfsharkVPN no longer uses numeric server IDs.",
"SurfsharkVPN: ignoring server_map entry '%s: %s', use a server name such as 'us-dal'",
region,
server,
)
@@ -240,9 +236,7 @@ class SurfsharkVPN(Proxy):
x for location, x in located if location.startswith(wanted)
]
if not servers:
raise ValueError(
f"No servers found in city '{city}'. Try a different city or check the city name spelling."
)
raise ValueError(f"No servers found in city '{city}'")
return servers
+3 -6
View File
@@ -21,9 +21,9 @@ class WindscribeVPN(Proxy):
code with a city ("ca:toronto"), and unshackle uses a pinned hostname before any server lookup.
"""
if not username:
raise ValueError("No Username was provided to the WindscribeVPN Proxy Service.")
raise ValueError("No username for the WindscribeVPN proxy provider")
if not password:
raise ValueError("No Password was provided to the WindscribeVPN Proxy Service.")
raise ValueError("No password for the WindscribeVPN proxy provider")
if server_map is not None and not isinstance(server_map, dict):
raise TypeError(f"Expected server_map to be a dict mapping a region to a hostname, not '{server_map!r}'.")
@@ -158,10 +158,7 @@ class WindscribeVPN(Proxy):
if hostnames:
return random.choice(hostnames)
elif city:
raise ValueError(
f"No servers found in city '{city}' for country code '{country_code}'. "
"Try a different city or check the city name spelling."
)
raise ValueError(f"No servers found in city '{city}' for country code '{country_code}'")
return None