SeafException GetSeafException <T>(SeafRequest <T> request, HttpResponseMessage response) { if (response.StatusCode == (System.Net.HttpStatusCode) 429) // TooManyRequests { IEnumerable <string> values; if (response.Headers.TryGetValues("X-Throttle-Wait-Seconds", out values)) { int seconds; if (int.TryParse(values.First(), out seconds)) { return(new SeafTooManyRequestsException(TimeSpan.FromSeconds(seconds))); } } // could not read the wait header return(new SeafTooManyRequestsException(TimeSpan.FromSeconds(30))); } else { return(new SeafException(request.GetSeafError(response))); } }