refactor: extract URL checking logic into separate method

This commit is contained in:
Paul Gauthier (aider) 2024-10-31 13:52:37 -07:00
parent 1ef60b5a40
commit 2b7584b651

View file

@ -1157,15 +1157,7 @@ class Coder:
self.io.tool_warning(err_msg)
retry_delay *= 2
if retry_delay > RETRY_TIMEOUT:
# Check for URLs in error message
# ai: refactor this into a function
url_pattern = re.compile(r"(https?://[^\s/$.?#].[^\s]*[^\s,.])")
urls = url_pattern.findall(str(err))
for url in urls:
if self.io.confirm_ask(
"View this URL from the error message?", subject=url
):
webbrowser.open(url)
self.check_and_offer_urls(str(err))
break
self.io.tool_output(f"Retrying in {retry_delay:.1f} seconds...")
time.sleep(retry_delay)