Postgres error handling

Closes #8485