Slide 31
Slide 31 text
Error Handling
def logError(action: String)(err: Throwable, details: RetryDetails): IO[Unit] = details match {
case WillDelayAndRetry(nextDelay: FiniteDuration, retriesSoFar: Int, cumulativeDelay: FiniteDuration) =>
IO {
logger.info(
s”Error has occurred on $action, retry[counter=$retriesSoFar] after ${nextDelay.toMillis} [ms] sleeping...”)
}
case GivingUp(totalRetries: Int, totalDelay: FiniteDuration) =>
IO {
logger.info(
s”Giving up on $action after $totalRetries retries, finally total delay was ${totalDelay.toMillis} [ms]”)
}
}
Logging or notification between attempts