fix: improved error handling for spider tool (#6835)
This commit is contained in:
parent
dd64e65ea0
commit
4be12b29b9
1 changed files with 9 additions and 3 deletions
|
|
@ -8,7 +8,13 @@ from core.tools.provider.builtin_tool_provider import BuiltinToolProviderControl
|
||||||
class SpiderProvider(BuiltinToolProviderController):
|
class SpiderProvider(BuiltinToolProviderController):
|
||||||
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
|
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
|
||||||
try:
|
try:
|
||||||
app = Spider(api_key=credentials["spider_api_key"])
|
app = Spider(api_key=credentials['spider_api_key'])
|
||||||
app.scrape_url(url="https://spider.cloud")
|
app.scrape_url(url='https://spider.cloud')
|
||||||
|
except AttributeError as e:
|
||||||
|
# Handle cases where NoneType is not iterable, which might indicate API issues
|
||||||
|
if 'NoneType' in str(e) and 'not iterable' in str(e):
|
||||||
|
raise ToolProviderCredentialValidationError('API is currently down, try again in 15 minutes', str(e))
|
||||||
|
else:
|
||||||
|
raise ToolProviderCredentialValidationError('An unexpected error occurred.', str(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ToolProviderCredentialValidationError(str(e))
|
raise ToolProviderCredentialValidationError('An unexpected error occurred.', str(e))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue