HTTPError carries the HTTP status and an error body. URLError describes connection failures. Avoid logging request headers or raw private inputs.
Example
from urllib.error import HTTPError, URLError
try:
result = client.models()
except HTTPError as error:
print("HTTP", error.code)
except URLError as error:
print("Connection failed", type(error.reason).__name__)