Handle exceptions correctly to not lock up gradles.
Added some debug logging