Make enumerate methods accept a callback that throws#144
Make enumerate methods accept a callback that throws#144DivineDominion merged 2 commits intoswiftcsv:masterfrom
enumerate methods accept a callback that throws#144Conversation
This updates the `enumerateAsArray` and `enumerateAsDict` methods to accept a row callback function that throws an error. If the function does throw an error it will be propogated to the caller of the `enumerate` method. This is inspired by #139 with the review comments addressed to hopefully get this functionality in to a release. Co-Authored-By: "Philip B." <145237+philipbel@users.noreply.github.com>
DivineDominion
left a comment
There was a problem hiding this comment.
Thank you for the submission!
Just one comment now that this is fresh on your mind, a point to discuss, where I don't know a good answer myself at the moment.
SwiftCSV/ParsingState.swift
Outdated
| let appendChar: (Character) -> Void | ||
| let finishField: () -> Void |
There was a problem hiding this comment.
Genuine question, not a back-handed request: What do you think about allowing all closures to throw? The public API makes sense this way. But it's a bit odd that eventually this only affects finishRow -- why can finishing a row fail, but not finishing a field?
There was a problem hiding this comment.
Yep that makes a lot of sense to me. I'd only updated what was necessary to make the public API allow throw functions, but keeping the private API consistent is a good idea.
I've pushed a commit which covers this.
|
Thanks a lot for contributing to SwiftCSV! We've invited you to join the SwiftCSV GitHub organization – no pressure to accept! If you'd like more information on what that means, check out our contributor guidelines. |
This follows up on the previous commit which made the `finishRow` closure of `ParsingState` allowed to throw an error, by updating the other two closures of the private API to also throw an error. Although this is not as neccessary for the private API, it keeps the closures consistent, and there's no reason why one should throw and the others should not.
|
Thank you! 🙌 |
This updates the
enumerateAsArrayandenumerateAsDictmethods to accept a row callback function that throws an error. If the function does throw an error it will be propogated to the caller of theenumeratemethod.This is inspired by #139 with the review comments addressed to hopefully get this functionality in to a release.