Added 'errorHandler' option to allow for custom error handling