diff --git a/backend/config.py b/backend/config.py index 6d0a199..0d2340a 100644 --- a/backend/config.py +++ b/backend/config.py @@ -75,19 +75,29 @@ class ProxyElem: for url in urls: if isinstance(url, tuple): clean_urls.append(url[0]) - link_requests.append( - ProxyCreateLink.parse_obj( - {"upstream": url[0], "ctype": url[1], "region": self.region} - ) - ) else: clean_urls.append(url) - link_requests.append( - ProxyCreateLink.parse_obj({"upstream": url, "region": self.region}) - ) if not isinstance(proxy_server, str): return clean_urls + try: + for url in urls: + if isinstance(url, tuple): + link_requests.append( + ProxyCreateLink.parse_obj( + {"upstream": url[0], "ctype": url[1], "region": self.region} + ) + ) + else: + link_requests.append( + ProxyCreateLink.parse_obj( + {"upstream": url, "region": self.region} + ) + ) + except pydantic.ValidationError as e: + logger.info(e) + return clean_urls + response_data: ProxyRequest response_data: ProxyResponse @@ -105,7 +115,7 @@ class ProxyElem: response_data = cast( ProxyResponse, ProxyResponse.parse_obj(await resp.text()) ) - except Exception as e: + except (aiohttp.ClientError, pydantic.ValidationError) as e: logger.info(e) else: ret_data = []