# exposed

Paul Higgins

03/01/2022, 12:33 AM
Got a question about exception handling when it comes to the fact that commits happen at the end of a transaction. Is my understanding correct that an exception in the sample code below would never be caught? Because the DAO style update doesn't commit to the DB until the end of the transaction we won't see an exception until that time, and that's outside the try/catch? Or is Exposed smart enough to know the exception happened as a result of that field update within the try block and catch the exception?
Copy code
transaction() {               
    try {
        record.field = newValue
    } catch (e: Exception) {
Updating for posterity: We did some testing on this today, and the exception doesn't come until the end of the transaction. So it won't be caught in the given example. Probably (didn't test this to confirm, but seems like it in the code) it comes when the entity cache is flushed, which for us was only at the end of the block.
🤔 1