Spaces:
Running
Running
Refactor app.py: Enhance error handling for API requests by adding a specific message for 403 Forbidden errors.
Browse files
app.py
CHANGED
|
@@ -539,6 +539,13 @@ def format_friendly_error(api_error):
|
|
| 539 |
elif "401" in api_error:
|
| 540 |
return "⚠️ Authentication error. Please check your API key."
|
| 541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 542 |
else:
|
| 543 |
return f"⚠️ Error processing request. Technical details: {api_error[:200]}"
|
| 544 |
|
|
|
|
| 539 |
elif "401" in api_error:
|
| 540 |
return "⚠️ Authentication error. Please check your API key."
|
| 541 |
|
| 542 |
+
elif "403" in api_error or "Forbidden" in api_error:
|
| 543 |
+
return ("⚠️ Access Forbidden\n\n"
|
| 544 |
+
"Please check:\n"
|
| 545 |
+
"1. Your Hugging Face token has proper permissions\n"
|
| 546 |
+
"2. You have access to the requested model\n"
|
| 547 |
+
"3. The model is currently available")
|
| 548 |
+
|
| 549 |
else:
|
| 550 |
return f"⚠️ Error processing request. Technical details: {api_error[:200]}"
|
| 551 |
|