mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-11 16:28:58 +08:00
fix: improved error handling for spider tool (#6835)
This commit is contained in:
parent
dd64e65ea0
commit
4be12b29b9
@ -8,7 +8,13 @@ from core.tools.provider.builtin_tool_provider import BuiltinToolProviderControl
|
||||
class SpiderProvider(BuiltinToolProviderController):
|
||||
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
|
||||
try:
|
||||
app = Spider(api_key=credentials["spider_api_key"])
|
||||
app.scrape_url(url="https://spider.cloud")
|
||||
app = Spider(api_key=credentials['spider_api_key'])
|
||||
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:
|
||||
raise ToolProviderCredentialValidationError(str(e))
|
||||
raise ToolProviderCredentialValidationError('An unexpected error occurred.', str(e))
|
||||
|
Loading…
x
Reference in New Issue
Block a user