Messy error messages across pcall()
I'm trying to clean up error handling in a plugin I'm writing and I see behavior I don't understand:
I'm in function A started with postAsyncTaskWithContext() and at the top of function A I call LrDialogs.attachErrorDialogToFunctionContext( context ).
- If I then throw an error from function A using LrErrors.throwUserError( 'test' ), I get a nice clean dialog box with the contents "test". Great - as expected.
- If I pcall() another function B from function A and call LrErrors.throwUserError( 'test' ) from B, the contents of the dialog box are "[string 'myfile.lua']:123: <AgErrorText>test</AgErrorText>". Not great. Any ideas why pcall is causing this?
Also: both dialog boxes happen twice - dismiss it and it comes right back with the same contents a second time. Dismiss that and it goes away.
If it helps, I am using johnrellis's debugging toolkit and my plugin is currently named with .lrdevplugin. Function A is actually invoked with :
LrFunctionContext.postAsyncTaskWithContext( 'myMain', Debug.showErrors ( myMain ) )
I also observe that when I pcall B from A, if I wrap that with LrTasks.pcall( Debug.showErrors( B ) ) then I get 3 error dialogs instead of 2 and the first one is clean and the last two are messy.
Hopefully this is some combo of me not understanding proper flow in LR error handling and/or John's Debug toolkit?
Thanks,
db
