mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-16 06:40:15 +02:00
Better Web Connector Logging (#2246)
This commit is contained in:
parent
336ddbd1fe
commit
3640d0c550
@ -84,6 +84,19 @@ def check_internet_connection(url: str) -> None:
|
||||
try:
|
||||
response = requests.get(url, timeout=3)
|
||||
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:
|
||||
cause = (
|
||||
e.args[0].reason
|
||||
@ -91,8 +104,8 @@ def check_internet_connection(url: str) -> None:
|
||||
else e.args
|
||||
)
|
||||
raise Exception(f"SSL error {str(cause)}")
|
||||
except (requests.RequestException, ValueError):
|
||||
raise Exception(f"Unable to reach {url} - check your internet connection")
|
||||
except (requests.RequestException, ValueError) as e:
|
||||
raise Exception(f"Unable to reach {url} - check your internet connection: {e}")
|
||||
|
||||
|
||||
def is_valid_url(url: str) -> bool:
|
||||
|
Loading…
x
Reference in New Issue
Block a user