Rafał Kuźmiński
06/10/2024, 1:42 PMobject NotExistingTable : IntIdTable("some_table")
suspend fun errorExample() {
try {
newSuspendedTransaction {
println("Called!")
delay(200)
NotExistingTable.selectAll().forEach { println(it) }
}
} catch (e: Exception) {
e.printStackTrace()
}
}
Running above code prints:
Called!
Called!
Called!
org.jetbrains.exposed.exceptions.ExposedSQLException: org.postgresql.util.PSQLException: This connection has been closed.
What is interesing, when I remove delay call (to simplify when I don't use any other suspend function inside newSuspendedTransaction) then it still calls code 3 times but erros is now correct:
Called!
Called!
Called!
org.jetbrains.exposed.exceptions.ExposedSQLException: org.postgresql.util.PSQLException: ERROR: relation "some_table" does not exist
Any ideas? What am I doing wrong? We are currently using Exposed 0.46.0. Coroutine scope used in example comes from Ktor routing.Chantal Loncle
06/10/2024, 2:42 PM