I could make the callback to waitForPerfEvent return an error as a second parameter. Seems cleaner than what you propose.