No error message in BackgroundWorker

I’m preloading assets using BackgroundWorker, but if I try to load an asset that doesn’t exist I get a hard crash without a useful error message:

libc++abi.dylib: terminating with uncaught exception of type Dynamic

I can wrap my Assets.getSound/Text/BitmapData calls in a try/catch and then print the error message that way, but it also might be nice if BackgroundWorker printed to console when an error message is thrown by Lime, so I’m not scratching my head trying to track down the cause of the crash.

So you’re thinking, instead of doing something like:

backgroundWorker.doWork.add (function (state) {
    try {
        // do stuff
    } catch (e) { backgroundWorker.sendError (e); }
});

…that we should try/catch the doWork internally, to send an error, if it was uncaught?

FWIW, Assets.loadSound and other calls should already be threaded, so that’s another way to do this. Assets.getSound (and friends) should return null if the asset does not exist, but not crash… though the Assets class may not be thread-safe. Assets.load should fire caching and other calls like that in the same thread, but do the actually loading operation in a background thread

I’m happy to follow the recommended practice with background workers–I hadn’t realized there was a backgroundWorker.sendError function, and I had also overlooked the Assets.loadSound possibility.