Skip to content

Commit 0764f6f

Browse files
fix: Raise the underlying urlerror while downloading example file (#4396)
While downloading the example file, if there is an `urllib.error.URLError` due to an `SSLError`, raise the underlying `SSLError`. For all other cases raise `RemoteFileNotFoundError` as before. Example SSLError: ``` ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007) ``` Showing the underlying error will help users to triage connection issues in their system, e.g. the above error is due to CA certificates are not installed on the system. Fluent bug - 1320755 --------- Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 939f4f8 commit 0764f6f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

doc/changelog.d/4396.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Raise the underlying urlerror while downloading example file

src/ansys/fluent/core/utils/networking.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from concurrent import futures
2626
import logging
2727
import socket
28+
import ssl
2829
from typing import Any
2930
import urllib.request
3031

@@ -130,12 +131,20 @@ def check_url_exists(url: str) -> bool:
130131
-------
131132
bool
132133
True if the URL exists, False otherwise
134+
135+
Raises
136+
------
137+
ssl.SSLError
138+
If there is an SSL error while checking the URL
133139
"""
134140
try:
135141
with urllib.request.urlopen(url) as response:
136142
return response.status == 200
137-
except Exception:
138-
return False
143+
except urllib.error.URLError as ex:
144+
if ex.__context__ and isinstance(ex.__context__, ssl.SSLError):
145+
raise ex.__context__
146+
else:
147+
return False
139148

140149

141150
def get_url_content(url: str) -> str:

0 commit comments

Comments
 (0)