Complete the code to declare a function that can rethrow errors from its closure parameter.
func perform(action: () throws -> Void) [1] { try action() }
The rethrows keyword allows the function to throw errors only if the closure parameter throws.
Complete the code to call a rethrowing function with a throwing closure.
[1] perform(action: { throw NSError(domain: "Error", code: 1) })
You must use try before the closure call because it can throw an error.
Fix the error in the function declaration to correctly rethrow errors from the closure.
func execute(task: () throws -> Void) [1] { try task() }
The function must be marked rethrows to propagate errors only if the closure throws.
Fill both blanks to define a rethrowing function that accepts a closure and calls it.
func runOperation(operation: () [1] -> Void) [2] { try operation() }
The closure parameter must be marked throws because it can throw errors, and the function must be rethrows to propagate those errors.
Fill all three blanks to create a rethrowing function that accepts a closure, calls it, and handles errors.
func handle(action: () [1] -> Void) [2] { do { try action() } catch { print([3]) } }
The closure is marked throws, the function rethrows, and the caught error is referenced as error inside the catch block.