maxAttempts function

PollStrategy maxAttempts(
  1. int count
)

Implementation

PollStrategy maxAttempts(int count) {
  int attempts = count;
  return (
    Principal canisterId,
    RequestId requestId,
    RequestStatusResponseStatus status,
  ) async {
    if (--attempts <= 0) {
      throw Exception(
        'Failed to retrieve a reply for request after $count attempts:\n'
        '  Request ID: ${requestIdToHex(requestId)}\n'
        '  Request status: ${status.name}\n',
      );
    }
  };
}