API overhaul
Especially w.r.t error handling
- #302
- #413
- #569
Not sure if this is related, but I recently changed Statement.next() to avoid using try!, as this occasionally caused crashes in my app. (Only when the SQLite DB was malformed, but still.) Instead, Statement.next now returns either a "success" result or the error thrown by .step().
In case you are interested, the commit at hand is https://github.com/MrMage/SQLite.swift/commit/c2f9cd0bbff4f175008ae331411a2cec04e1c48b. I'm not suggesting cherry-picking this 1-by-1, but if you are about to overhaul the API anyway, consider changing Statement.next() to return a "success-or-error" type instead of using try!. Adding throws to the method signature would be the nicer approach, but unfortunately that would break Statements conformance to IteratorProtocol.
@MrMage thanks! this has already been discussed in #569. A Either type solution was proposed there as well. Right now there's a "stop-gap" solution in 0.11.4 with #726 but I'm not completely happy with that. The FailableIterator type introduced there doesn't really work well with the remaining Swift types. For 0.12 we could rethink some of these approaches.
Thanks for the elaboration! Looking forward to whatever improvements you come up with :-) I think the Cursor approach is not bad, but I would also suggest making that return RowResults instead of optional Rows.