Display error details and tech wizard notice on errors
- Show actual error message in code block for debugging - Add 'tech wizard needs to take a look' notice - Content policy violations don't show tech notice (user issue)
This commit is contained in:
@@ -205,9 +205,13 @@ class AIChatCog(commands.Cog):
|
|||||||
error: The exception that occurred
|
error: The exception that occurred
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A user-friendly error message
|
A user-friendly error message with error details
|
||||||
"""
|
"""
|
||||||
error_str = str(error).lower()
|
error_str = str(error).lower()
|
||||||
|
error_details = str(error)
|
||||||
|
|
||||||
|
# Base message asking for tech wizard
|
||||||
|
tech_wizard_notice = "\n\n🔧 *A tech wizard needs to take a look at this!*"
|
||||||
|
|
||||||
# Check for credit/quota/billing errors
|
# Check for credit/quota/billing errors
|
||||||
credit_keywords = [
|
credit_keywords = [
|
||||||
@@ -226,25 +230,39 @@ class AIChatCog(commands.Cog):
|
|||||||
]
|
]
|
||||||
|
|
||||||
if any(keyword in error_str for keyword in credit_keywords):
|
if any(keyword in error_str for keyword in credit_keywords):
|
||||||
return "I'm currently out of API credits. Please try again later or contact the bot administrator."
|
return (
|
||||||
|
f"I'm currently out of API credits. Please try again later."
|
||||||
|
f"{tech_wizard_notice}"
|
||||||
|
f"\n\n```\nError: {error_details}\n```"
|
||||||
|
)
|
||||||
|
|
||||||
# Check for authentication errors
|
# Check for authentication errors
|
||||||
auth_keywords = ["invalid api key", "unauthorized", "authentication", "invalid_api_key"]
|
auth_keywords = ["invalid api key", "unauthorized", "authentication", "invalid_api_key"]
|
||||||
if any(keyword in error_str for keyword in auth_keywords):
|
if any(keyword in error_str for keyword in auth_keywords):
|
||||||
return (
|
return (
|
||||||
"There's an issue with my API configuration. Please contact the bot administrator."
|
f"There's an issue with my API configuration."
|
||||||
|
f"{tech_wizard_notice}"
|
||||||
|
f"\n\n```\nError: {error_details}\n```"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check for model errors
|
# Check for model errors
|
||||||
if "model" in error_str and ("not found" in error_str or "does not exist" in error_str):
|
if "model" in error_str and ("not found" in error_str or "does not exist" in error_str):
|
||||||
return "The configured AI model is not available. Please contact the bot administrator."
|
return (
|
||||||
|
f"The configured AI model is not available."
|
||||||
|
f"{tech_wizard_notice}"
|
||||||
|
f"\n\n```\nError: {error_details}\n```"
|
||||||
|
)
|
||||||
|
|
||||||
# Check for content policy violations
|
# Check for content policy violations (no tech wizard needed for this)
|
||||||
if "content policy" in error_str or "safety" in error_str or "blocked" in error_str:
|
if "content policy" in error_str or "safety" in error_str or "blocked" in error_str:
|
||||||
return "I can't respond to that request due to content policy restrictions."
|
return "I can't respond to that request due to content policy restrictions."
|
||||||
|
|
||||||
# Default error message
|
# Default error message
|
||||||
return "Sorry, I encountered an error. Please try again."
|
return (
|
||||||
|
f"Sorry, I encountered an error."
|
||||||
|
f"{tech_wizard_notice}"
|
||||||
|
f"\n\n```\nError: {error_details}\n```"
|
||||||
|
)
|
||||||
|
|
||||||
def _extract_message_content(self, message: discord.Message) -> str:
|
def _extract_message_content(self, message: discord.Message) -> str:
|
||||||
"""Extract the actual message content, removing bot mentions."""
|
"""Extract the actual message content, removing bot mentions."""
|
||||||
|
|||||||
Reference in New Issue
Block a user