improve errors

This commit is contained in:
Roy Olav Purser 2022-02-12 13:31:09 +01:00
parent bb7e2cd7f3
commit fb48a2181a
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -75,17 +75,27 @@ class ProxyElem:
for url in urls: for url in urls:
if isinstance(url, tuple): if isinstance(url, tuple):
clean_urls.append(url[0]) clean_urls.append(url[0])
else:
clean_urls.append(url)
if not isinstance(proxy_server, str):
return clean_urls
try:
for url in urls:
if isinstance(url, tuple):
link_requests.append( link_requests.append(
ProxyCreateLink.parse_obj( ProxyCreateLink.parse_obj(
{"upstream": url[0], "ctype": url[1], "region": self.region} {"upstream": url[0], "ctype": url[1], "region": self.region}
) )
) )
else: else:
clean_urls.append(url)
link_requests.append( link_requests.append(
ProxyCreateLink.parse_obj({"upstream": url, "region": self.region}) ProxyCreateLink.parse_obj(
{"upstream": url, "region": self.region}
) )
if not isinstance(proxy_server, str): )
except pydantic.ValidationError as e:
logger.info(e)
return clean_urls return clean_urls
response_data: ProxyRequest response_data: ProxyRequest
@ -105,7 +115,7 @@ class ProxyElem:
response_data = cast( response_data = cast(
ProxyResponse, ProxyResponse.parse_obj(await resp.text()) ProxyResponse, ProxyResponse.parse_obj(await resp.text())
) )
except Exception as e: except (aiohttp.ClientError, pydantic.ValidationError) as e:
logger.info(e) logger.info(e)
else: else:
ret_data = [] ret_data = []