perform(synchronous:) is not a rethrowing method as documented #159

Closed
opened 2025-12-29 15:25:57 +01:00 by adam · 3 comments
Owner

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 15:25:57 +01:00
adam closed this issue 2025-12-29 15:25:57 +01:00
Author
Owner

@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)
@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)
Author
Owner

@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.

@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.
Author
Owner

@JohnEstropia commented on GitHub (Aug 15, 2017):

Thanks, I see the confusion. Will reword similar places in the documentations 👍

@JohnEstropia commented on GitHub (Aug 15, 2017): Thanks, I see the confusion. Will reword similar places in the documentations 👍
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#159