Skip to content

Commit 6b9f95a

Browse files
committed
Fix urllib exception handling
1 parent 41ca3c3 commit 6b9f95a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

osg-test-log-viewer

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ def load_logdata_from_url(url):
9595
try:
9696
urlhandle = urllib.request.urlopen(url)
9797
return load_logdata_from_handle(urlhandle)
98-
except urllib.error as e:
99-
print("Error reading URL %s: %s" % (url, e.strerror), file=sys.stderr)
98+
except urllib.error.HTTPError as e:
99+
print("HTTP error code %d reading URL %s: %s" % (e.code, url, e.reason), file=sys.stderr)
100+
sys.exit(1)
101+
except urllib.error.URLError as e:
102+
print("Error reading URL %s: %s" % (url, e.reason), file=sys.stderr)
100103
sys.exit(1)
101104

102105

0 commit comments

Comments
 (0)