Handle multiple exceptions in UDF

Add-in Express™ Support Service
That's what is more important than anything else

Handle multiple exceptions in UDF
 
nwein




Posts: 577
Joined: 2011-03-28
As a rule of thumb I always wrap my UDFs in a try...catch block so that any exception will be caught and logged (inside the catch).
The problem arises where a user opens a workbook with the same UDF used, say, 1000s of times (different parameters or not, doesn't really matter), and there's an error in the UDF (due to unforeseen circumstances) - we get 1000s of entries in our log which is not really desirable.
I thought of going about using an error queue, flushed at set intervals, so that only unique errors will be added to the queue, and a timer will log and flush the queue every x seconds/minutes/whatever.
The problem I can see with such approach is the use of a Timer in my XLL module, something you guys don't recommend.
The timer will not access the object module or interact with Excel whatsoever, but I wanted to ask if you can see any potential issues with that.
Also, if you can think of another way to approach this I'd be happy to hear any such suggestions.
Thanks!
Posted 26 Jun, 2015 11:24:48 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Nir,

You can use a background thread and a timer on it to handle the queue.


Andrei Smolin
Add-in Express Team Leader
Posted 29 Jun, 2015 05:37:46 Top
nwein




Posts: 577
Joined: 2011-03-28
Great, thank you!
Posted 29 Jun, 2015 10:10:37 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Welcome!


Andrei Smolin
Add-in Express Team Leader
Posted 30 Jun, 2015 01:46:27 Top