Open hutou opened 4 years ago
The unhandled error is triggered by the DBCONN.close
that is why it is unhandled: there is no rescue
to catch it.
It seems that https://github.com/crystal-lang/crystal-sqlite3/blob/master/src/sqlite3/statement.cr#L37 should not be checked according to https://stackoverflow.com/a/8391872/30948 🤔
In the second example, there is effectively no row to return (insert A, filter Z), plus there is no print of code
.
Workaround to ignore the exception in DBCONN.close
: DBCONN.close rescue nil
Thanks for the explanations and the workaround.
It’s still something that should be fixed. I will leave this open until then.
Thanks for reporting it.
Hi, I am trying to understand how exceptions are handled in Crystal-sqlite3. Given the following code :
output is :
Why does Crystal tell me the exception is unhandled when the displayed message in the rescue clause "proves" it was rescued ?
I noticed that if I comment out the DBCONN.close statement, I only get the "Already in database" message, no more unhandled exception.
If however, I run the following program :
the output is a bare
So, no more unhandled exception and I'm somewhat puzzled : can you enlighten me on this? Are there different "levels" of exceptions ? I also noticed that putting the DBCONN.close in an at_exit statement produce the same "unhandled exception" for the first code snippet.
Thanks