Skip to content

Commit

Permalink
Merge pull request #84 from touchlab/kpg/better_errors
Browse files Browse the repository at this point in the history
Better messages
  • Loading branch information
kpgalligan authored Aug 29, 2022
2 parents 86851ea + d4ed6c2 commit 0f409b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.code.style=official

GROUP=co.touchlab
VERSION_NAME=1.2.0
VERSION_NAME=1.2.1
KOTLIN_VERSION=1.6.20

kotlin.native.ignoreDisabledTargets=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ internal class ActualSqliteStatement(private val db: SqliteDatabase, private val
private inline fun opResult(db: SqliteDatabase, block: () -> Int) {
val err = block()
if (err != SQLITE_OK) {
throw sqlException(db.logger, db.config, "Sqlite operation failure", err)
val error = sqlite3_errmsg(db.dbPointer)?.toKString()
throw sqlException(db.logger, db.config, "Sqlite operation failure ${error?:""}", err)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ internal class SqliteDatabase(path: String, label: String, val logger: Logger, p
fun rawExecSql(sqlString: String){
val err = sqlite3_exec(dbPointer, sqlString, null, null, null)
if (err != SQLITE_OK) {
throw sqlException(logger, config, "error rawExecSql: $sqlString", err)
val error = sqlite3_errmsg(dbPointer)?.toKString()
throw sqlException(logger, config, "error rawExecSql: $sqlString, ${error?:""}", err)
}
}

Expand Down Expand Up @@ -97,8 +98,9 @@ internal fun dbOpen(
if (lookasideSlotSize >= 0 && lookasideSlotCount >= 0) {
val err = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, null, lookasideSlotSize, lookasideSlotCount);
if (err != SQLITE_OK) {
val error = sqlite3_errmsg(db)?.toKString()
sqlite3_close(db)
throw sqlException(logging, SqliteDatabaseConfig(path, label), "Cannot set lookaside : sqlite3_db_config(..., ${lookasideSlotSize}, %${lookasideSlotCount}) failed", err)
throw sqlException(logging, SqliteDatabaseConfig(path, label), "Cannot set lookaside : sqlite3_db_config(..., ${lookasideSlotSize}, %${lookasideSlotCount}) failed, ${error?:""}", err)
}
}

Expand Down

0 comments on commit 0f409b3

Please sign in to comment.