Better database connection error handling