public async Task <AbilityDraftMatch> FetchGame(string matchId) { //create api request var matchRequest = new OpenDotaMatchAPIRequest(requestSender, matchId); //send request var stringResult = await SendHttpRequestAndBundleExceptions(matchRequest); //try to convert string to AbilityDraftMatch return(await ConvertJSONStringToAbilityDraftMatch(stringResult)); }
private async Task <string> SendHttpRequestAndBundleExceptions(OpenDotaMatchAPIRequest matchRequest) { try { return(await rateLimitedRequestDispatcher.MakeAPIRequestAsync(matchRequest, CancellationToken.None, TimeSpan.FromSeconds(10))); } catch (TaskCanceledException e) { //timed out throw new GameFetcherException("The request timed out.", e); } catch (HttpRequestException e) { //The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout. throw new GameFetcherException("The external request failed. There could be an issue with network connectivity, DNS failure, server certificate validation or timeout", e); } }