File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 11Unreleased
22
3+ * Improve formatting for `NameResolutionError` (Timo Brembeck, #192)
34* Fix internal redirect checker (Timo Ludwig, #180)
45* Fix SSL status of unreachable domains (Timo Ludwig, #184)
56* Fix URL message for internal server errorrs (Timo Ludwig, #182)
Original file line number Diff line number Diff line change @@ -567,6 +567,9 @@ def format_connection_error(e):
567567 # If the underlying cause is a new connection error, provide additional formatting
568568 if reason .startswith ("NewConnectionError" ):
569569 return format_new_connection_error (reason )
570+ # If the underlying cause is a name resolution error, provide additional formatting
571+ if reason .startswith ("NameResolutionError" ):
572+ return format_name_resolution_error (reason )
570573 # If the underlying cause is an SSL error, provide additional formatting
571574 if reason .startswith ("SSLError" ):
572575 return format_ssl_error (reason )
@@ -586,6 +589,19 @@ def format_new_connection_error(reason):
586589 return reason
587590
588591
592+ def format_name_resolution_error (reason ):
593+ """
594+ Helper function to provide better readable output of name resolution errors thrown by urllib3
595+ """
596+ resolution_reason = re .search (
597+ r"NameResolutionError\([\"']<urllib3\.connection\.HTTPSConnection object at 0x[0-9a-f]+>: (.+)[\"']\)" ,
598+ reason ,
599+ )
600+ if resolution_reason :
601+ return f"Name Resolution Error: { resolution_reason [1 ]} "
602+ return reason
603+
604+
589605def format_ssl_error (reason ):
590606 """
591607 Helper function to provide better readable output of SSL errors thrown by urllib3
Original file line number Diff line number Diff line change @@ -443,7 +443,7 @@ def test_external_check_unreachable(self):
443443 for attr in [uv .message , uv .get_message , uv .error_message ]:
444444 self .assertEqual (
445445 attr ,
446- 'New Connection Error: Failed to establish a new connection: [Errno -2] Name or service not known' ,
446+ "Name Resolution Error: Failed to resolve 'invalid' ( [Errno -2] Name or service not known)" ,
447447 )
448448 self .assertEqual (uv .anchor_message , '' )
449449 self .assertEqual (uv .ssl_status , None )
You can’t perform that action at this time.
0 commit comments