Conversation
src/tiny_sqlite.nim
Outdated
| finally: | ||
| if ok: | ||
| db.exec("COMMIT") | ||
| db.exec(if ok: "COMMIT" else: "ROLLBACK") |
There was a problem hiding this comment.
This change is why the tests are failing. The body is allowed to contain a return, break, or similar so ok = true might not execute. That the old code is no longer valid seems like an oversight in Nims exception tracking since a bare raise statement cannot raise anything that couldn't already be raised by the code in the try block :/
There was a problem hiding this comment.
You are right! I reverted this change, but had to add more stuff so that compiler would not mark every execMany/execScript call as possibly raising an Exception. Now the tests are passing.
There was a problem hiding this comment.
But then I thought if we could understand in the finally block whether an exception is being raised, then we would not have to mess with except/raise; and so it seems, getCurrentException() can be used. So the last version is much simpler.
…xplicitly to pacify Nim exception tracking
|
Ok, here is finally what I had in mind ;) |
These changes make the code compile and work with Nim 2.0rc1.