Error Handling and Exception Management in PL/pgSQL
Error Handling and Exception Management in PL/pgSQL
Production PL/pgSQL functions cannot simply crash when something unexpected happens. A failed payment function that throws an unhandled exception and rolls back a partially-completed transaction is worse than one that catches the error, logs it, and returns a structured failure response. This lesson covers PostgreSQL's exception system in depth.