Skip to content

Commit

Permalink
Add RetryLogging.onError
Browse files Browse the repository at this point in the history
  • Loading branch information
finestructure committed Jul 19, 2023
1 parent 6cb6161 commit b5ff96b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/Retry/Retry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum Retry {
do {
return try block()
} catch {
logger.onError(label: label, error: error)
lastError = "\(error)"
guard retriesLeft > 0 else { break }
let delay = backedOffDelay(baseDelay: delay, attempt: currentTry)
Expand All @@ -56,6 +57,7 @@ public enum Retry {
public protocol RetryLogging {
func onStartOfRetry(label: String, attempt: Int)
func onStartOfDelay(label: String, delay: Double)
func onError(label: String, error: Error)
}


Expand All @@ -69,6 +71,10 @@ public struct DefaultLogger: RetryLogging {
public func onStartOfDelay(label: String, delay: Double) {
print("Retrying in \(delay) seconds ...")
}

public func onError(label: String, error: Error) {
print(error)
}
}


0 comments on commit b5ff96b

Please sign in to comment.