refactor: move fallback error templates to shared directory with improved naming
Reorganize error template structure to consolidate shared templates in a dedicated location. Changes: - Move templates/fallback/* to templates/shared/ with -fallback suffix - 404.html → 404-fallback.html - 500.html → 500-fallback.html - generic.html → generic-fallback.html - Update error_renderer.py to use new template paths - Modified template selection logic in _find_template() - Updated documentation strings to reflect new paths - Update error rendering documentation - HTML_ERROR_RENDERING_FLOW_DIAGRAM.md: Updated diagrams and examples - ERROR_RENDERING_DEVELOPER_DOCUMENTATION.md: Updated file structure and paths Benefits: - Clearer organization with all shared templates in shared/ directory - Consistent naming convention (-fallback suffix) indicates purpose - Aligns with existing cdn-fallback.html in same directory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -69,8 +69,8 @@ class ErrorPageRenderer:
|
||||
Template Selection Priority:
|
||||
1. Context-specific error page: {context}/errors/{status_code}.html
|
||||
2. Context-specific generic: {context}/errors/generic.html
|
||||
3. Fallback error page: fallback/{status_code}.html
|
||||
4. Fallback generic: fallback/generic.html
|
||||
3. Shared fallback error page: shared/{status_code}-fallback.html
|
||||
4. Shared fallback generic: shared/generic-fallback.html
|
||||
|
||||
Args:
|
||||
request: FastAPI request object
|
||||
@@ -150,8 +150,8 @@ class ErrorPageRenderer:
|
||||
Priority:
|
||||
1. {context}/errors/{status_code}.html
|
||||
2. {context}/errors/generic.html
|
||||
3. fallback/{status_code}.html
|
||||
4. fallback/generic.html
|
||||
3. shared/{status_code}-fallback.html
|
||||
4. shared/generic-fallback.html
|
||||
"""
|
||||
templates_dir = ErrorPageRenderer.get_templates_dir()
|
||||
|
||||
@@ -176,13 +176,13 @@ class ErrorPageRenderer:
|
||||
if (templates_dir / generic_template).exists():
|
||||
return generic_template
|
||||
|
||||
# Try fallback status code template
|
||||
fallback_specific = f"fallback/{status_code}.html"
|
||||
# Try shared fallback status code template
|
||||
fallback_specific = f"shared/{status_code}-fallback.html"
|
||||
if (templates_dir / fallback_specific).exists():
|
||||
return fallback_specific
|
||||
|
||||
# Use fallback generic template (must exist)
|
||||
return "fallback/generic.html"
|
||||
# Use shared fallback generic template (must exist)
|
||||
return "shared/generic-fallback.html"
|
||||
|
||||
@staticmethod
|
||||
def _prepare_template_data(
|
||||
|
||||
Reference in New Issue
Block a user