dave08
02/23/2025, 11:29 AMdave08
02/23/2025, 11:31 AMsuspend fun <T> R2dbcDatabase.runSafeQuery(query: Query<T>): T = try {
runQuery(query)
} catch (e: Exception) {
val dryRunResult = query.dryRun(db.config)
if (dryRunResult.throwable != null) {
val querySql = dryRunResult.sql + " [" + dryRunResult.args.joinToString(",") { it.any.toString() } + "]"
logger.error(dryRunResult.throwable) { "Failed to run query: $querySql" }
} else {
logger.error(e) { "Failed to run query: ${dryRunResult.sqlWithArgs}" }
throw e
}
throw e
}
dave08
02/23/2025, 11:32 AMToshihiro Nakamura
02/24/2025, 1:24 AMRegular runtime failures only give a small part of the sql that had bad grammar... which isn’t too helpful in tracking down the problemWhen an exception occurs in the R2DBC driver, Komapper returns that exception to the caller. It might be helpful to ensure that the R2DBC driver is configured to include sufficient information in the exception.
dave08
02/24/2025, 10:12 AMToshihiro Nakamura
02/24/2025, 1:14 PMorg.komapper.core.Statement
object.
If this change were implemented, would it meet your expectations?
Please note that the type of the thrown exception will change, which could affect any code that uses exception types for conditional branching.dave08
02/24/2025, 1:21 PM