Check exception for URLs, offer to open in a browser, with user-friendly error msgs.
(self, exc, friendly_msg=None)
| 944 | message = self.reflected_message |
| 945 | |
| 946 | def check_and_open_urls(self, exc, friendly_msg=None): |
| 947 | """Check exception for URLs, offer to open in a browser, with user-friendly error msgs.""" |
| 948 | text = str(exc) |
| 949 | |
| 950 | if friendly_msg: |
| 951 | self.io.tool_warning(text) |
| 952 | self.io.tool_error(f"{friendly_msg}") |
| 953 | else: |
| 954 | self.io.tool_error(text) |
| 955 | |
| 956 | # Exclude double quotes from the matched URL characters |
| 957 | url_pattern = re.compile(r'(https?://[^\s/$.?#].[^\s"]*)') |
| 958 | urls = list(set(url_pattern.findall(text))) # Use set to remove duplicates |
| 959 | for url in urls: |
| 960 | url = url.rstrip(".',\"}") # Added } to the characters to strip |
| 961 | self.io.offer_url(url) |
| 962 | return urls |
| 963 | |
| 964 | def check_for_urls(self, inp: str) -> List[str]: |
| 965 | """Check input for URLs and offer to add them to the chat.""" |
no test coverage detected