Could you wrap this in a try/catch and call your onFailure() in the catch.