Register handlers with @app.errorhandler(codeorexception) so every error returns a consistent body. For JSON APIs, convert HTTPException into JSON and log unexpected exceptions. Built-in logger app.logger is a standard logging.Logger. In production, configure logging once at startup (level, format, handler) — Gunicorn and container platforms collect stdout. Status Raise with 400 Bad Request abort(400) 401 / 403 abort(401) / abort(403) 404 abort(404) or db.getor404() 409 Conflict abort(409) 500 any unhandled exception