in atr/server.py [0:0]
def register_routes(app: base.QuartApp) -> ModuleType:
# NOTE: These imports are for their side effects only
import atr.routes.modules as modules
# Add a global error handler to show helpful error messages with tracebacks
@app.errorhandler(Exception)
async def handle_any_exception(error: Exception) -> Any:
import traceback
# Required to give to the error.html template
tb = traceback.format_exc()
app.logger.exception("Unhandled exception")
return await quart.render_template("error.html", error=str(error), traceback=tb, status_code=500), 500
@app.errorhandler(base.ASFQuartException)
async def handle_asfquart_exception(error: base.ASFQuartException) -> Any:
# TODO: Figure out why pyright doesn't know about this attribute
if not hasattr(error, "errorcode"):
errorcode = 500
else:
errorcode = getattr(error, "errorcode")
return await quart.render_template("error.html", error=str(error), status_code=errorcode), errorcode
# Add a global error handler in case a page does not exist.
@app.errorhandler(404)
async def handle_not_found(error: Exception) -> Any:
return await quart.render_template("notfound.html", error="404 Not Found", traceback="", status_code=404), 404
return modules