@Override
public <T> T execute(Request<T> req, Map<String,String> extraHeaders, String key) {
try {
return executeAsync(req, extraHeaders, key).get(30L, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new HerokuAPIException("request interrupted", e);
} catch (ExecutionException e) {
if (e.getCause() != null && e.getCause().getCause() instanceof RequestFailedException) {
throw (RequestFailedException) e.getCause().getCause();
}
throw new HerokuAPIException("execution exception", e.getCause());
} catch (TimeoutException e) {
throw new HerokuAPIException("request timeout after 30 sec", e.getCause());
}
}