/// <summary> /// Throws an exception for the response if none of the statuses match. /// </summary> /// <param name="errorProvider">The error provider.</param> /// <param name="response">The response.</param> /// <param name="validStatuses">The valid statuses.</param> public static void ThrowIfStatusMismatch(this IErrorProvider errorProvider, IRestResponse response, params HttpStatusCode[] validStatuses) { bool mismatch = validStatuses.All(status => response.StatusCode != status); if (mismatch) { errorProvider.ThrowFromResponse(response); } }