Centralized exception handling in REST APIs with Spring and FastAPI
Problem. An API often handles exceptions in one of two bad ways. It catches them and logs nothing, so nobody can find the error later. Or it lets them reach the client, and the response shows class names, table names and SQL.
Fix. Log the stack trace in one global handler and return a small JSON error.