batman
This commit is contained in:
commit
66f9ce3614
33 changed files with 2271 additions and 0 deletions
32
app/utils/error_handlers.py
Normal file
32
app/utils/error_handlers.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
"""
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue