Skip to content

Fix: propagate errors in CIDSet.for_each()#81

Open
sumanjeet0012 wants to merge 1 commit into
ipld:masterfrom
sumanjeet0012:fix-69
Open

Fix: propagate errors in CIDSet.for_each()#81
sumanjeet0012 wants to merge 1 commit into
ipld:masterfrom
sumanjeet0012:fix-69

Conversation

@sumanjeet0012

Copy link
Copy Markdown
Contributor

Closes #69

Description

This PR updates CIDSet.for_each() so that it stops iteration and returns the first error from the callback, effectively matching the behavior of Go's Set.ForEach().

Previously, for_each ignored return values and would continue iterating even if the function had an error.

Changes

  • Updated CIDSet.for_each(func) to catch any exception raised by func and return it.
  • Also, if func itself returns an Exception object, for_each will stop iteration and return it.
  • Added tests to ensure CIDSet.for_each() stops and propagates errors properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CIDSet.for_each() doesn't propagate errors — Go's ForEach() does

1 participant