recover(_:)

When the current EventLoopFuture<Value> is in an error state, run the provided callback, which can recover from the error and return a new value of type Value. The provided callback may not throw, so this function should be used when the error is always recoverable.

EventLoopFuture.swift:780
@preconcurrency func recover(_ callback: @escaping (any Error) -> Value) -> EventLoopFuture<Value>

Parameters

callback

Function that will receive the error value of this EventLoopFuture and return a new value lifted into a new EventLoopFuture.

Returns

A future that will receive the recovered value.

Operations performed in recover should not block, or they will block the entire event loop. recover is intended for use when you have the ability to synchronously recover from errors.