Error Handling
etl4s provides built-in failure handling:
.withRetry¶
Retry failed operations with exponential backoff using .withRetry:
import etl4s._
var attempts = 0
val riskyTransformWithRetry = Transform[Int, String] {
n =>
attempts += 1
if (attempts < 3) throw new RuntimeException(s"Attempt $attempts failed")
else s"Success after $attempts attempts"
}.withRetry(maxAttempts = 3, initialDelayMs = 10)
val pipeline = Extract(42) ~> riskyTransformWithRetry
pipeline.unsafeRun(())
.onFailure¶
Catch exceptions and provide fallback values using .onFailure: