Improve db connection error trapping