Handle exception if can't connect to database