chore: sqlite make sure code is always run (#2891)

This commit is contained in:
Ivan FB 2024-07-10 18:34:28 +02:00 committed by GitHub
parent e1518cf9ff
commit 4ac4ab2a41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 14 deletions

View File

@ -234,6 +234,8 @@ proc query*(
return err($sqlite3_errstr(v))
return ok gotResults
except Exception, CatchableError:
error "exception in query", query = query, error = getCurrentExceptionMsg()
# release implicit transaction
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible

View File

@ -1,6 +1,7 @@
{.push raises: [].}
import std/[options, sequtils], stew/byteutils, sqlite3_abi, results
import chronicles
import
../../../common/databases/db_sqlite,
../../../common/databases/common,
@ -427,6 +428,9 @@ proc execSelectMessagesV2WithLimitStmt(
else:
return err($sqlite3_errstr(v))
except Exception, CatchableError:
error "exception in execSelectMessagesV2WithLimitStmt",
error = getCurrentExceptionMsg()
# release implicit transaction
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible
@ -498,6 +502,8 @@ proc execSelectMessageByHash(
else:
return err($sqlite3_errstr(v))
except Exception, CatchableError:
error "exception in execSelectMessageByHash", error = getCurrentExceptionMsg()
# release implicit transaction
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible
@ -629,6 +635,9 @@ proc execSelectMessagesWithLimitStmt(
else:
return err($sqlite3_errstr(v))
except Exception, CatchableError:
error "exception in execSelectMessagesWithLimitStmt",
error = getCurrentExceptionMsg()
# release implicit transaction
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible