Skip to content

Commit bb355d0

Browse files
committed
Proxy authentication exception catch reworked
1 parent 6858bab commit bb355d0

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

pulpcore/download/http.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import aiohttp
44
import asyncio
55
import backoff
6+
import socket
67

78
from .base import BaseDownloader, DownloadResult
89
from pulpcore.exceptions import (
@@ -272,7 +273,7 @@ async def download_wrapper():
272273
e.message,
273274
)
274275
)
275-
raise e
276+
raise ProxyAuthenticationRequiredError(self.proxy)
276277

277278
return await download_wrapper()
278279

@@ -299,10 +300,11 @@ async def _run(self, extra_data=None):
299300
self.raise_for_status(response)
300301
to_return = await self._handle_response(response)
301302
await response.release()
302-
except aiohttp.ClientConnectorDNSError:
303-
raise DnsDomainNameException(self.url)
304-
except aiohttp.ClientHttpProxyError:
305-
raise ProxyAuthenticationRequiredError(self.proxy)
303+
except aiohttp.ClientConnectorError as e:
304+
# Check if this is a DNS error
305+
if isinstance(e.os_error, socket.gaierror):
306+
raise DnsDomainNameException(self.url)
307+
raise
306308
if self._close_session_on_finalize:
307309
await self.session.close()
308310
return to_return

pulpcore/tasking/tasks.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ def _execute_task(task):
8282
except Exception:
8383
exc_type, exc, tb = sys.exc_info()
8484
log_task_failed(task, exc_type, exc, tb, domain)
85-
# Generic exception for user
86-
safe_exc = Exception("An internal error occured.")
85+
# Generic exception for user (temporarily including debug info)
86+
safe_exc = Exception(
87+
f"An internal error occured. " f"[DEBUG: {exc_type.__name__}: {str(exc)}]"
88+
)
8789
task.set_failed(safe_exc)
8890
send_task_notification(task)
8991
else:
@@ -114,8 +116,10 @@ async def _aexecute_task(task):
114116
except Exception:
115117
exc_type, exc, tb = sys.exc_info()
116118
log_task_failed(task, exc_type, exc, tb, domain)
117-
# Generic exception for user
118-
safe_exc = Exception("An internal error occured.")
119+
# Generic exception for user (temporarily including debug info)
120+
safe_exc = Exception(
121+
f"An internal error occured. " f"[DEBUG: {exc_type.__name__}: {str(exc)}]"
122+
)
119123
await sync_to_async(task.set_failed)(safe_exc)
120124
send_task_notification(task)
121125
else:

0 commit comments

Comments
 (0)