Originally created by @sidmani on GitHub (Aug 15, 2017).
The documentation for DataStack.perform(synchronous:) states:
"Any errors thrown from inside the task will be rethrown from perform(synchronous:)".
However, the signature is marked throws, not rethrows. public func perform<T>(synchronous task: ((_ transaction: SynchronousDataTransaction) throws -> T), waitForAllObservers: Bool = true) throws -> T
Documentation error?
Originally created by @sidmani on GitHub (Aug 15, 2017).
The documentation for `DataStack.perform(synchronous:)` states:
"Any errors thrown from inside the `task` will be rethrown from `perform(synchronous:)`".
However, the signature is marked `throws`, not `rethrows`.
`public func perform<T>(synchronous task: ((_ transaction: SynchronousDataTransaction) throws -> T), waitForAllObservers: Bool = true) throws -> T`
Documentation error?
adam
added the question label 2025-12-29 18:23:51 +01:00
perform(synchronous:) just promises to "rethrow", that is to propagate, any errors you throw from inside the closure, not that it accepts non-throwing closures. It's explicitly throws because
The only way to cancel a transaction is to call throw transaction.cancel()
Declaring rethrows gives the illusion that non-throwing closures will never fail, which is not true (save errors may still be emitted)
@JohnEstropia commented on GitHub (Aug 15, 2017):
`perform(synchronous:)` just promises to "rethrow", that is to propagate, any errors you `throw` from inside the closure, not that it accepts non-throwing closures. It's explicitly `throws` because
1. The only way to cancel a transaction is to call `throw transaction.cancel()`
2. Declaring `rethrows` gives the illusion that non-throwing closures will never fail, which is not true (save errors may still be emitted)
Gotcha, I think changing the word "rethrow" to "propagate" or something in the doc would make it clearer since rethrows is a keyword.
@sidmani commented on GitHub (Aug 15, 2017):
Gotcha, I think changing the word "rethrow" to "propagate" or something in the doc would make it clearer since rethrows is a keyword.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @sidmani on GitHub (Aug 15, 2017).
The documentation for
DataStack.perform(synchronous:)states:"Any errors thrown from inside the
taskwill be rethrown fromperform(synchronous:)".However, the signature is marked
throws, notrethrows.public func perform<T>(synchronous task: ((_ transaction: SynchronousDataTransaction) throws -> T), waitForAllObservers: Bool = true) throws -> TDocumentation error?
@JohnEstropia commented on GitHub (Aug 15, 2017):
perform(synchronous:)just promises to "rethrow", that is to propagate, any errors youthrowfrom inside the closure, not that it accepts non-throwing closures. It's explicitlythrowsbecausethrow transaction.cancel()rethrowsgives the illusion that non-throwing closures will never fail, which is not true (save errors may still be emitted)@sidmani commented on GitHub (Aug 15, 2017):
Gotcha, I think changing the word "rethrow" to "propagate" or something in the doc would make it clearer since rethrows is a keyword.
@JohnEstropia commented on GitHub (Aug 15, 2017):
Thanks, I see the confusion. Will reword similar places in the documentations 👍