Skip to main content
Participating Frequently
Mar 9, 2025 4:07 PM UTC
Question

how do I thow error from catalog:withWriteAccessDo() ?

How can I thow error from catalog:withWriteAccessDo() ?

 

I was to throw an error when calling function inside catalog:withWriteAccessDo() and handle it outside of catalog:withWriteAccessDo().

 

How to do it?

1 reply

johnrellis
Legend
Mar 10, 2025 3:07 AM UTC

Here's an example:

local success, err = LrTasks.pcall (function ()
    catalog:withWriteAccessDo ("Test", function ()
        error ("My error") end) end)

 

 Note that you must use LrTasks.pcall() rather than the Lua pcall() because of LR's tasking architecture.

Translate