Gracefully handle errors in threaded worker (fixes GH-254)