Transaction function errors

Hello,

When throwing an exception in a transaction function as per the docs the transaction is rolled back as expected, but no exception is logged or thrown back to the caller so there is no way to know that the transaction failed, and what the actual exception was (that I can see)

Is there a way, perhaps something similar to this v1 workaround that could be used in v2?

Thanks

Hi @wkok for v2 see the xt$txs table for this information, mentioned briefly here. Currently the level of information exposed is fairly limited but we can conceivably extend it in quite a few directions, e.g. storing first-class user-provided transaction metadata

Hey @refset, thanks for the link to the transaction table information, Iā€™m now able to retrieve the :committed? state of the transaction :+1:

To add to your note of possibly extending the information stored - it would be really helpful if the actual exception detail could be stored as well :slightly_smiling_face:

for example a transaction function throwing:

(xt/submit-tx
    xt-node
    [(xt/put-fn :throw-some-error
                '(fn [args]
                   (throw (ex-info "Oops, here's some.."
                                   {:valuable "information"}))))])

currently loses the exception detail in the transaction table:

[#:xt{:committed? false,
      :error
      #xt/runtime-err {:xtdb.error/error-type :runtime-error, :xtdb.error/error-key :xtdb.call/error-evaluating-tx-fn, :xtdb.error/message "Runtime error: ':xtdb.call/error-evaluating-tx-fn'", :fn-id :throw-some-error, :args [{}]}}]
1 Like