maxAttempts function

PollStrategy maxAttempts(
  1. int count
)

Implementation

PollStrategy maxAttempts(int count) {
  var attempts = count;
  return (
    Principal canisterId,
    RequestId requestId,
    String status,
  ) async {
    if (--attempts <= 0) {
      // ignore: prefer_adjacent_string_concatenation
      throw "Failed to retrieve a reply for request after $count attempts:\n"
              // ignore: prefer_adjacent_string_concatenation
              "  Request ID: ${requestIdToHex(requestId)}\n" +
          "  Request status: $status\n";
    }
  };
}