Bug 913809 - Proper psql error handling

https://bugzilla.redhat.com/show_bug.cgi?id=913809

This adds some extra error handling when using psql in a scaled application if the database server is stopped.