error handling for db connection