Fixed problem with exceptions in Postgres