mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-08 21:50:12 +02:00
Better Web Connector Logging (#2246)
This commit is contained in:
@ -84,6 +84,19 @@ def check_internet_connection(url: str) -> None:
|
|||||||
try:
|
try:
|
||||||
response = requests.get(url, timeout=3)
|
response = requests.get(url, timeout=3)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
except requests.exceptions.HTTPError as e:
|
||||||
|
status_code = e.response.status_code
|
||||||
|
error_msg = {
|
||||||
|
400: "Bad Request",
|
||||||
|
401: "Unauthorized",
|
||||||
|
403: "Forbidden",
|
||||||
|
404: "Not Found",
|
||||||
|
500: "Internal Server Error",
|
||||||
|
502: "Bad Gateway",
|
||||||
|
503: "Service Unavailable",
|
||||||
|
504: "Gateway Timeout",
|
||||||
|
}.get(status_code, "HTTP Error")
|
||||||
|
raise Exception(f"{error_msg} ({status_code}) for {url} - {e}")
|
||||||
except requests.exceptions.SSLError as e:
|
except requests.exceptions.SSLError as e:
|
||||||
cause = (
|
cause = (
|
||||||
e.args[0].reason
|
e.args[0].reason
|
||||||
@ -91,8 +104,8 @@ def check_internet_connection(url: str) -> None:
|
|||||||
else e.args
|
else e.args
|
||||||
)
|
)
|
||||||
raise Exception(f"SSL error {str(cause)}")
|
raise Exception(f"SSL error {str(cause)}")
|
||||||
except (requests.RequestException, ValueError):
|
except (requests.RequestException, ValueError) as e:
|
||||||
raise Exception(f"Unable to reach {url} - check your internet connection")
|
raise Exception(f"Unable to reach {url} - check your internet connection: {e}")
|
||||||
|
|
||||||
|
|
||||||
def is_valid_url(url: str) -> bool:
|
def is_valid_url(url: str) -> bool:
|
||||||
|
Reference in New Issue
Block a user