Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Fix error propagation in iterator #60

Merged
merged 2 commits into from
Aug 8, 2018
Merged

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Aug 1, 2018

This fixes a minor issue where the iterator, after calling the run function, doesn't pass along its error to the callback.

This fixes a minor issue where the iterator, after calling the `run` function, doesn't pass along its error to the callback.
@coveralls
Copy link

coveralls commented Aug 1, 2018

Coverage Status

Coverage remained the same at 96.84% when pulling fcc98b1 on s1na:patch-1 into 3752761 on ethereumjs:master.

@vpulim
Copy link
Contributor

vpulim commented Aug 2, 2018

@s1na Good catch. Thanks!

However, the fix still won't catch errors generated by _saveHeads() but something like this should do the trick:

(err) => err ? cb(err) : self._saveHeads(cb)

Also, it would be good to add a new test case for this to test/index.js. For example:

function iterateError (done) {
  blockchain.iterator('error', function (block, reorg, cb) {
    cb(new Error('iterator func error'))
  }, function (err) {
    t.ok(err, 'should catch iterator func error')
    done()
  })
}

Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
@s1na
Copy link
Contributor Author

s1na commented Aug 2, 2018

@vpulim Sorry for the incomplete PR, and thanks for the help :) I've updated it with the points you mentioned.

Copy link
Contributor

@vpulim vpulim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Looks good to me!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants