ThrowingFuture

public final class ThrowingFuture<Wrapped> : Future<Wrapped>

A Future with support for error handling.

expensiveComputation().then {
   print("result: \($0)")
}.onError{
   print("error: \($0)")
}

The !> operator also throws when used with a ThrowingFuture.

let result = try !>expensiveComputation()

Not handling errors coming from a ThrowingFuture will result in an error.

  • Initialize a new future and execute the given closure. The closure is executed asynchronously on a special dispatch queue.

    Declaration

    Swift

    public init(executeThrowing closure: () throws -> (Wrapped))
  • If an error is thrown for this Future, handle it trough the given handler.

    Declaration

    Swift

    public func onError(handler: (ErrorType) -> ()) -> Self
  • Initialize a new future and execute the given closure. The closure is executed asynchronously on a special dispatch queue.

    Declaration

    Swift

    public convenience init(@autoclosure(escaping) executeThrowing closure: () throws -> (Wrapped))