Instance Methodvapor 4.114.1Vapor->NIOCore

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.

OptionalType.swift:13
func unwrap(or error: @autoclosure @escaping () -> Error) -> EventLoopFuture<Value.WrappedType>

Parameters

error

Error to throw if the value is nil. This is captured with @autoclosure to avoid initialize the Error unless needed.

print(futureString) // Future<String?>
futureString.unwrap(or: MyError()) // Future<String>