added shouldDisplayAlertOnError flag to control alert display on failure