Initializer

init(catching:)

Creates a new result by evaluating a throwing closure, capturing the returned value as a success, or any thrown error as a failure.

Declaration

init(catching body: () throws -> Success)

Parameters

body

A throwing closure to evaluate.

See Also

Converting a Throwing Expression to a Result

Preserving the Results of a Throwing Expression

Call the initializer that wraps a throwing expression when you need to serialize or memoize the result.