sourize commited on
Commit ·
9c23281
1
Parent(s): 77a99c7
Updated Code
Browse files- app.py +12 -3
- utils/error_handler.py +18 -30
app.py
CHANGED
|
@@ -539,14 +539,19 @@ def process_video_generation(generator, user_prompt, selected_model, video_quali
|
|
| 539 |
st.markdown(f'<div class="error-box">❌ {error_info["user_message"]}</div>',
|
| 540 |
unsafe_allow_html=True)
|
| 541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 542 |
suggestions = ErrorHandler.suggest_fixes(result)
|
| 543 |
if suggestions:
|
| 544 |
st.markdown("**Possible solutions:**")
|
| 545 |
for suggestion in suggestions:
|
| 546 |
st.markdown(f"• {suggestion}")
|
| 547 |
-
|
| 548 |
-
if logs and st.checkbox("Show error details"):
|
| 549 |
-
st.text_area("Error Details", logs, height=200)
|
| 550 |
|
| 551 |
# Cleanup after everything is done
|
| 552 |
if temp_dir and os.path.exists(temp_dir):
|
|
@@ -561,6 +566,10 @@ def process_video_generation(generator, user_prompt, selected_model, video_quali
|
|
| 561 |
st.markdown(f'<div class="error-box">❌ {error_info["user_message"]}</div>',
|
| 562 |
unsafe_allow_html=True)
|
| 563 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
suggestions = ErrorHandler.suggest_fixes(str(e))
|
| 565 |
if suggestions:
|
| 566 |
st.markdown("**Try these solutions:**")
|
|
|
|
| 539 |
st.markdown(f'<div class="error-box">❌ {error_info["user_message"]}</div>',
|
| 540 |
unsafe_allow_html=True)
|
| 541 |
|
| 542 |
+
# Always show error details
|
| 543 |
+
st.markdown("**Error Details:**")
|
| 544 |
+
st.text_area("Error Message", result, height=100)
|
| 545 |
+
|
| 546 |
+
if logs:
|
| 547 |
+
st.markdown("**Rendering Logs:**")
|
| 548 |
+
st.text_area("Logs", logs, height=200)
|
| 549 |
+
|
| 550 |
suggestions = ErrorHandler.suggest_fixes(result)
|
| 551 |
if suggestions:
|
| 552 |
st.markdown("**Possible solutions:**")
|
| 553 |
for suggestion in suggestions:
|
| 554 |
st.markdown(f"• {suggestion}")
|
|
|
|
|
|
|
|
|
|
| 555 |
|
| 556 |
# Cleanup after everything is done
|
| 557 |
if temp_dir and os.path.exists(temp_dir):
|
|
|
|
| 566 |
st.markdown(f'<div class="error-box">❌ {error_info["user_message"]}</div>',
|
| 567 |
unsafe_allow_html=True)
|
| 568 |
|
| 569 |
+
# Always show error details
|
| 570 |
+
st.markdown("**Error Details:**")
|
| 571 |
+
st.text_area("Error Message", str(e), height=100)
|
| 572 |
+
|
| 573 |
suggestions = ErrorHandler.suggest_fixes(str(e))
|
| 574 |
if suggestions:
|
| 575 |
st.markdown("**Try these solutions:**")
|
utils/error_handler.py
CHANGED
|
@@ -55,18 +55,23 @@ class ErrorHandler:
|
|
| 55 |
r"ffmpeg.*not found": "FFmpegError",
|
| 56 |
r"No such file or directory": "FileNotFoundError",
|
| 57 |
r"MemoryError": "MemoryError",
|
| 58 |
-
r"Permission denied": "PermissionError"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
# Error type to user-friendly message mapping
|
| 62 |
ERROR_MESSAGES = {
|
| 63 |
ErrorType.RENDERING_ERROR: {
|
| 64 |
-
"user_message": "Failed to render the animation. Please
|
| 65 |
"suggestions": [
|
| 66 |
"Try reducing the complexity of your animation",
|
| 67 |
"Lower the video quality setting",
|
| 68 |
"Check if Manim is properly installed",
|
| 69 |
-
"Ensure you have enough system resources"
|
|
|
|
| 70 |
]
|
| 71 |
},
|
| 72 |
ErrorType.CODE_GENERATION_ERROR: {
|
|
@@ -88,12 +93,13 @@ class ErrorHandler:
|
|
| 88 |
]
|
| 89 |
},
|
| 90 |
ErrorType.SYSTEM_ERROR: {
|
| 91 |
-
"user_message": "A system error occurred. Please
|
| 92 |
"suggestions": [
|
| 93 |
"Refresh the page and try again",
|
| 94 |
"Check your internet connection",
|
| 95 |
"Ensure you have the latest version of the application",
|
| 96 |
-
"Clear your browser cache"
|
|
|
|
| 97 |
]
|
| 98 |
},
|
| 99 |
ErrorType.VALIDATION_ERROR: {
|
|
@@ -165,13 +171,13 @@ class ErrorHandler:
|
|
| 165 |
error_info = cls.ERROR_MESSAGES.get(error_type)
|
| 166 |
else:
|
| 167 |
# Try to infer error type from message
|
| 168 |
-
error_type = cls.
|
| 169 |
error_info = cls.ERROR_MESSAGES.get(error_type)
|
| 170 |
|
| 171 |
if not error_info:
|
| 172 |
# Fallback to generic error
|
| 173 |
error_info = {
|
| 174 |
-
"user_message": "An
|
| 175 |
"suggestions": [
|
| 176 |
"Refresh the page",
|
| 177 |
"Try a different prompt",
|
|
@@ -192,37 +198,19 @@ class ErrorHandler:
|
|
| 192 |
Returns:
|
| 193 |
List of suggested fixes
|
| 194 |
"""
|
| 195 |
-
error_type = cls.
|
| 196 |
error_info = cls.ERROR_MESSAGES.get(error_type)
|
| 197 |
|
| 198 |
if error_info and "suggestions" in error_info:
|
| 199 |
return error_info["suggestions"]
|
| 200 |
|
| 201 |
return [
|
| 202 |
-
"Try
|
| 203 |
-
"
|
| 204 |
-
"
|
| 205 |
-
"
|
| 206 |
]
|
| 207 |
|
| 208 |
-
@classmethod
|
| 209 |
-
def _infer_error_type(cls, error_message: str) -> ErrorType:
|
| 210 |
-
"""Infer the type of error from the error message.
|
| 211 |
-
|
| 212 |
-
Args:
|
| 213 |
-
error_message: The error message to analyze
|
| 214 |
-
|
| 215 |
-
Returns:
|
| 216 |
-
Inferred ErrorType
|
| 217 |
-
"""
|
| 218 |
-
error_message_lower = error_message.lower()
|
| 219 |
-
|
| 220 |
-
for pattern, error_type in cls.ERROR_PATTERNS.items():
|
| 221 |
-
if pattern in error_message_lower:
|
| 222 |
-
return error_type
|
| 223 |
-
|
| 224 |
-
return ErrorType.SYSTEM_ERROR # Default to system error if no pattern matches
|
| 225 |
-
|
| 226 |
@classmethod
|
| 227 |
def get_debug_info(cls, error_message: str, code: str = None) -> Dict[str, any]:
|
| 228 |
"""Get detailed debug information for error reporting"""
|
|
|
|
| 55 |
r"ffmpeg.*not found": "FFmpegError",
|
| 56 |
r"No such file or directory": "FileNotFoundError",
|
| 57 |
r"MemoryError": "MemoryError",
|
| 58 |
+
r"Permission denied": "PermissionError",
|
| 59 |
+
r"Error:": "RenderingError",
|
| 60 |
+
r"Exception:": "RenderingError",
|
| 61 |
+
r"Failed to": "RenderingError",
|
| 62 |
+
r"Could not": "RenderingError"
|
| 63 |
}
|
| 64 |
|
| 65 |
# Error type to user-friendly message mapping
|
| 66 |
ERROR_MESSAGES = {
|
| 67 |
ErrorType.RENDERING_ERROR: {
|
| 68 |
+
"user_message": "Failed to render the animation. Please check the error details below.",
|
| 69 |
"suggestions": [
|
| 70 |
"Try reducing the complexity of your animation",
|
| 71 |
"Lower the video quality setting",
|
| 72 |
"Check if Manim is properly installed",
|
| 73 |
+
"Ensure you have enough system resources",
|
| 74 |
+
"Check the error details for specific issues"
|
| 75 |
]
|
| 76 |
},
|
| 77 |
ErrorType.CODE_GENERATION_ERROR: {
|
|
|
|
| 93 |
]
|
| 94 |
},
|
| 95 |
ErrorType.SYSTEM_ERROR: {
|
| 96 |
+
"user_message": "A system error occurred. Please check the error details below.",
|
| 97 |
"suggestions": [
|
| 98 |
"Refresh the page and try again",
|
| 99 |
"Check your internet connection",
|
| 100 |
"Ensure you have the latest version of the application",
|
| 101 |
+
"Clear your browser cache",
|
| 102 |
+
"Check the error details for specific issues"
|
| 103 |
]
|
| 104 |
},
|
| 105 |
ErrorType.VALIDATION_ERROR: {
|
|
|
|
| 171 |
error_info = cls.ERROR_MESSAGES.get(error_type)
|
| 172 |
else:
|
| 173 |
# Try to infer error type from message
|
| 174 |
+
error_type = cls.classify_error(error_message)
|
| 175 |
error_info = cls.ERROR_MESSAGES.get(error_type)
|
| 176 |
|
| 177 |
if not error_info:
|
| 178 |
# Fallback to generic error
|
| 179 |
error_info = {
|
| 180 |
+
"user_message": f"An error occurred: {error_message}",
|
| 181 |
"suggestions": [
|
| 182 |
"Refresh the page",
|
| 183 |
"Try a different prompt",
|
|
|
|
| 198 |
Returns:
|
| 199 |
List of suggested fixes
|
| 200 |
"""
|
| 201 |
+
error_type = cls.classify_error(error_message)
|
| 202 |
error_info = cls.ERROR_MESSAGES.get(error_type)
|
| 203 |
|
| 204 |
if error_info and "suggestions" in error_info:
|
| 205 |
return error_info["suggestions"]
|
| 206 |
|
| 207 |
return [
|
| 208 |
+
"Try a simpler animation",
|
| 209 |
+
"Check if Manim is properly installed",
|
| 210 |
+
"Ensure you have enough system resources",
|
| 211 |
+
"Try a different AI model"
|
| 212 |
]
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
@classmethod
|
| 215 |
def get_debug_info(cls, error_message: str, code: str = None) -> Dict[str, any]:
|
| 216 |
"""Get detailed debug information for error reporting"""
|