From 64405c301b19d298a152ca57b36d2f58e5bc20af Mon Sep 17 00:00:00 2001 From: fumoboy007 <2100868+fumoboy007@users.noreply.github.com> Date: Mon, 8 Jan 2024 01:28:19 -0800 Subject: [PATCH] Add messages to user-facing preconditions. --- .../Backoff/Algorithms/FullJitterExponentialBackoff.swift | 4 ++-- .../Retry/RetryableRequest/RetryableRequest+SafeRetry.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Retry/Backoff/Algorithms/FullJitterExponentialBackoff.swift b/Sources/Retry/Backoff/Algorithms/FullJitterExponentialBackoff.swift index 27ab843..5069554 100644 --- a/Sources/Retry/Backoff/Algorithms/FullJitterExponentialBackoff.swift +++ b/Sources/Retry/Backoff/Algorithms/FullJitterExponentialBackoff.swift @@ -44,10 +44,10 @@ where ClockType: Clock, RandomNumberGeneratorType: RandomNumberGenerator { self.clockMinResolution = clock.minimumResolution self.baseDelayInClockTicks = baseDelay / clockMinResolution - precondition(baseDelayInClockTicks > 0) + precondition(baseDelayInClockTicks > 0, "The base delay must be greater than zero.") if let maxDelay { - precondition(maxDelay >= baseDelay) + precondition(maxDelay >= baseDelay, "The max delay must be greater than or equal to the base delay.") self.maxDelayInClockTicks = min(maxDelay / clockMinResolution, Double(Self.implicitMaxDelayInClockTicks)) } else { diff --git a/Sources/Retry/RetryableRequest/RetryableRequest+SafeRetry.swift b/Sources/Retry/RetryableRequest/RetryableRequest+SafeRetry.swift index adbd4ef..c01fc02 100644 --- a/Sources/Retry/RetryableRequest/RetryableRequest+SafeRetry.swift +++ b/Sources/Retry/RetryableRequest/RetryableRequest+SafeRetry.swift @@ -292,7 +292,7 @@ extension RetryableRequest { with configuration: RetryConfiguration, @_inheritActorContext @_implicitSelfCapture operation: (Self) async throws -> ReturnType ) async throws -> ReturnType { - precondition(isIdempotent) + precondition(isIdempotent, "The request is not idempotent: `\(self)`.") return try await unsafeRetryIgnoringIdempotency(with: configuration, operation: operation)