Rulga commited on
Commit
20e06cf
·
1 Parent(s): 2be5d0e

Refactor app.py: Enhance error handling for API requests by adding a specific message for 403 Forbidden errors.

Browse files
Files changed (1) hide show
  1. app.py +7 -0
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