32 lines
No EOL
875 B
Python
32 lines
No EOL
875 B
Python
"""
|
|
Error handlers for the NetViz application.
|
|
"""
|
|
import traceback
|
|
from flask import render_template, current_app
|
|
|
|
|
|
def register_error_handlers(app):
|
|
"""
|
|
Register error handlers for the application.
|
|
|
|
Args:
|
|
app: The Flask application
|
|
"""
|
|
@app.errorhandler(403)
|
|
def forbidden_error(error):
|
|
return render_template('errors/403.html'), 403
|
|
|
|
@app.errorhandler(404)
|
|
def not_found_error(error):
|
|
return render_template('errors/404.html'), 404
|
|
|
|
@app.errorhandler(500)
|
|
def internal_error(error):
|
|
# Log the error
|
|
current_app.logger.error(f"Server Error: {error}")
|
|
current_app.logger.error(traceback.format_exc())
|
|
return render_template('errors/500.html'), 500
|
|
|
|
@app.errorhandler(429)
|
|
def ratelimit_error(error):
|
|
return render_template('errors/429.html'), 429 |