from __future__ import annotations import uuid from quart import jsonify # The app's single JSON error shape + the two guards that pair with it, so every # blueprint returns errors and parses path ids the same way instead of hand-building # `jsonify({"error": ...}), code` and try/except uuid blocks at ~35 call sites. def json_error(message: str, status: int): """A JSON error body + status: ({"error": message}, status).""" return jsonify({"error": message}), status def not_found(): """404 with the standard body — by far the most common error in the note routes.""" return json_error("not found", 404) def parse_uuid(raw: object) -> uuid.UUID | None: """Parse a path/body UUID, returning None on anything malformed. Pair with not_found() for the ubiquitous 'bad id in the URL → 404' guard.""" try: return uuid.UUID(str(raw)) except (ValueError, TypeError): return None