Addon Manager: Add try/except to integer conversion

This commit is contained in:
Chris Hennes
2022-11-07 13:55:31 -06:00
committed by wwmayer
parent 5225a5f904
commit d767a923a3

View File

@@ -212,7 +212,17 @@ if HAVE_QTNETWORK:
) # This may still be QNetworkProxy.NoProxy
elif userProxyCheck:
host, _, port_string = proxy_string.rpartition(":")
port = 0 if not port_string else int(port_string)
try:
port = 0 if not port_string else int(port_string)
except ValueError:
FreeCAD.Console.PrintError(
translate(
"AddonsInstaller",
"Failed to convert the specified proxy port '{}' to a port number",
).format(port_string)
+ "\n"
)
port = 0
# For now assume an HttpProxy, but eventually this should be a parameter
proxy = QtNetwork.QNetworkProxy(
QtNetwork.QNetworkProxy.HttpProxy, host, port