Implementing the equivalent of an autonomous transaction / Oracle pragma in postgresql
https://aws.amazon.com/blogs/database/migrating-oracle-autonomous-transactions-to-postgresql/ in other words how to write a error log to a table and separately commit that record