Using Higher Order Functions to Retry Errors In Kotlin

Опубликовано: 18 Март 2026
на канале: Pairing with Duncan
1,182
54

Sometimes errors are just 'random'. If they are, and are infrequent enough, then just retrying the operation may be enough to proceed, and we shouldn't bother our users with the failure.

In this episode we first of all write some tests to characterize the errors that we are seeing with the ValueElf service, and then implement a generic functional retry to make them (appear to) go away.

This is Part 47 of an exploration of where a Test Driven Development implementation of the Gilded Rose stock control system might take us in Kotlin. You can see the whole series as a playlist
   • All Gilded Rose Episodes  
and the code on GitHub
https://github.com/dmcg/gilded-rose-tdd

This sub-series on error handling is also a playlist
   • Kotlin Error Handling - Exceptions, Nulls,...  

If you like this, you’ll probably like the book Java to Kotlin, A Refactoring Guidebook
http://java-to-kotlin.dev. Chapter 19 covers error handling.