Description
I realize that calling methods on a database that's been closed is not a good idea. However, when calling a method like each
on the closed database, the error reported is out of memory
. The underlying db is nulled out on close (which makes sense). But then, in the handleError
method:
Database.prototype.handleError = function(returnCode) {
var errmsg;
if (returnCode === SQLite.OK) {
return null;
} else {
errmsg = sqlite3_errmsg(this.db);
throw new Error(errmsg);
}
};
We're passing null
into the sqlite3_errmsg
. That in turn causes it to report it as a memory allocation error.
Ideally, the error reported would be something more intuitive. I bring this up because I am now closing databases that we are no longer using in an effort to fix a real memory allocation error. However, in the process of doing so, I accidentally closed a database I shouldn't have and continued to get what looked like memory errors. It wasn't until later that I realized this message was inaccurate.