PMKCascadingFinalizer
public class PMKCascadingFinalizer
extension PMKCascadingFinalizer: _PMKCatchWrappers
Undocumented
-
The provided closure executes when this promise rejects.
Rejecting a promise cascades: rejecting all subsequent promises (unless recover is invoked) thus you will typically place your catch at the end of a chain. Often utility promises will not have a catch, instead delegating the error handling to the caller.
See also
CancellationDeclaration
Swift
@discardableResult public func `catch`(on: Dispatcher = conf.D.return, policy: CatchPolicy = conf.catchPolicy, _ body: @escaping (Error) -> Void) -> PMKFinalizerParameters
onThe dispatcher that executes the provided closure.
policyThe default policy does not execute your handler for cancellation errors.
bodyThe handler to execute if this promise is rejected.
Return Value
A promise finalizer.
-
The provided closure executes when this promise rejects with the specific error passed in. A final
catchis still required at the end of the chain.Rejecting a promise cascades: rejecting all subsequent promises (unless recover is invoked) thus you will typically place your catch at the end of a chain. Often utility promises will not have a catch, instead delegating the error handling to the caller.
Note
Since this method handles only specific errors, supplying aCatchPolicyis unsupported.See also
CancellationDeclaration
Swift
public func `catch`<E>(only: E, on: Dispatcher = conf.D.return, _ body: @escaping (E) -> Void) -> PMKCascadingFinalizer where E : Equatable, E : ErrorParameters
onlyThe specific error to be caught and handled (e.g.,
PMKError.emptySequence).onThe dispatcher that executes the provided closure.
bodyThe handler to execute if this promise is rejected with the provided error.
Return Value
A promise finalizer that accepts additional
catchclauses. -
The provided closure executes when this promise rejects with an error of the type passed in. A final
catchis still required at the end of the chain.Rejecting a promise cascades: rejecting all subsequent promises (unless recover is invoked) thus you will typically place your catch at the end of a chain. Often utility promises will not have a catch, instead delegating the error handling to the caller.
See also
CancellationDeclaration
Swift
public func `catch`<E>(only: E.Type, on: Dispatcher = conf.D.return, policy: CatchPolicy = conf.catchPolicy, _ body: @escaping (E) -> Void) -> PMKCascadingFinalizer where E : ErrorParameters
onlyThe error type to be caught and handled (e.g.,
PMKError).onThe dispatcher that executes the provided closure.
bodyThe handler to execute if this promise is rejected with the provided error type.
Return Value
A promise finalizer that accepts additional
catchclauses. -
Consumes the Swift unused-result warning.
Note
You shouldcatch, but in situations where you know you don’t need acatch,cauterizemakes your intentions clear.Declaration
Swift
@discardableResult public func cauterize() -> PMKFinalizer
View on GitHub
PMKCascadingFinalizer Class Reference