Factor out exception handling in federation_client