Added exception handling to the :with_result thread