Does anyone know how to return a value from a tran...
# exposed
j
Does anyone know how to return a value from a transaction while having a try/catch to handle errors? I posted about in this issue here, because the only way I've found to work around this is by having a separate variable and assigning to that, which is pretty gross.
Copy code
var a = -1
newSuspendedTransaction {
    try {
        a = Users.insert {
            it[username] = model.username
        } get Users.userId
    } catch (e: Exception){

    }
}

return a
Any ideas as to how I can return the value from the transaction while also handling error? I've tried handling the error outside the transaction, but for some reason, transactions don't let errors bubble up
t
Did you try to commit transaction before end of
try
block like adviced here?