Instance Method
unwrap(or:)
Unwraps an
Optional value contained inside a Future’s expectation. If the optional resolves to nil (.none), the supplied error will be thrown instead.func unwrap(or error: @autoclosure @escaping @Sendable () -> any Error) -> EventLoopFuture<Value.WrappedType>
Parameters
errorErrorto throw if the value isnil. This is captured with@autoclosureto avoid initialize theErrorunless needed.
Discussion
print(futureString) // Future<String?>
futureString.unwrap(or: MyError()) // Future<String>