mirror of
https://github.com/langgenius/dify.git
synced 2026-09-24 23:22:26 +08:00
fix(watercrawl): handle non-json auth errors (#37498)
This commit is contained in:
@@ -37,10 +37,16 @@ class WatercrawlAuth(ApiKeyAuthBase):
|
||||
|
||||
def _handle_error(self, response):
|
||||
if response.status_code in {402, 409, 500}:
|
||||
error_message = response.json().get("error", "Unknown error occurred")
|
||||
try:
|
||||
error_message = response.json().get("error", "Unknown error occurred")
|
||||
except ValueError:
|
||||
error_message = response.text or "Unknown error occurred"
|
||||
raise Exception(f"Failed to authorize. Status code: {response.status_code}. Error: {error_message}")
|
||||
else:
|
||||
if response.text:
|
||||
error_message = json.loads(response.text).get("error", "Unknown error occurred")
|
||||
try:
|
||||
error_message = json.loads(response.text).get("error", "Unknown error occurred")
|
||||
except ValueError:
|
||||
error_message = response.text
|
||||
raise Exception(f"Failed to authorize. Status code: {response.status_code}. Error: {error_message}")
|
||||
raise Exception(f"Unexpected error occurred while trying to authorize. Status code: {response.status_code}")
|
||||
|
||||
Reference in New Issue
Block a user