Improve error handling of addEventWithCallback and uploadEventsWithCallback