-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot get Error from callback #230
Comments
+1, for now error passed to callback will be always nil and break will never occur. I think the right api would be: func ArrayEach(data []byte, cb func(value []byte, dataType ValueType, offset int) error, keys ...string) (offset int, err error) |
@PiotrKozimor you are right that callback at the moment never receive the error. But I guess proper way to handle it will be smth like: Instead of Lines 1028 to 1030 in 09bcf22
Do
Well it does not make TOO much sense from API point of view, since it always returns on the first error. But at least it does not break API (I really care about backward compatibility). I've set v2 milestone, so when we do next major release, we can "remove" err object from callback or fix it in another way. |
@buger It would make sense as a temporary, compatible fix. Going back to my breaking suggestion - when error is returned from callback, iterating over array would be stopped and this error would be returned from |
Agree with @PiotrKozimor recommendation, I would like that behavior and that would bring it inline with ObjectEach, I think. |
jsonparser/parser.go
Line 1040 in 09bcf22
The text was updated successfully, but these errors were encountered: