Skip to content

Commit 0f409b3

Browse files
authored
Merge pull request #84 from touchlab/kpg/better_errors
Better messages
2 parents 86851ea + d4ed6c2 commit 0f409b3

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
kotlin.code.style=official
22

33
GROUP=co.touchlab
4-
VERSION_NAME=1.2.0
4+
VERSION_NAME=1.2.1
55
KOTLIN_VERSION=1.6.20
66

77
kotlin.native.ignoreDisabledTargets=true

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/interop/ActualSqliteStatement.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ internal class ActualSqliteStatement(private val db: SqliteDatabase, private val
129129
private inline fun opResult(db: SqliteDatabase, block: () -> Int) {
130130
val err = block()
131131
if (err != SQLITE_OK) {
132-
throw sqlException(db.logger, db.config, "Sqlite operation failure", err)
132+
val error = sqlite3_errmsg(db.dbPointer)?.toKString()
133+
throw sqlException(db.logger, db.config, "Sqlite operation failure ${error?:""}", err)
133134
}
134135
}
135136

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/interop/SqliteDatabase.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ internal class SqliteDatabase(path: String, label: String, val logger: Logger, p
4040
fun rawExecSql(sqlString: String){
4141
val err = sqlite3_exec(dbPointer, sqlString, null, null, null)
4242
if (err != SQLITE_OK) {
43-
throw sqlException(logger, config, "error rawExecSql: $sqlString", err)
43+
val error = sqlite3_errmsg(dbPointer)?.toKString()
44+
throw sqlException(logger, config, "error rawExecSql: $sqlString, ${error?:""}", err)
4445
}
4546
}
4647

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

0 commit comments

Comments
 (0)