Add error handler in getNextSequence

Ensures errors are returned to the callback rather than halting the app process