Conversation
ArchimedesTrajano
left a comment
There was a problem hiding this comment.
Thank you! I think this can be useful until the error is exposed, and potentially even longer. This covers my needs.
|
@MojtabaHs Thanks for exploring! While we definitely want to do this, it's something we also want to take some care to design properly, either determining a finite set of enum cases that is fully extensible in the future for our needs, or losing the closed enum entirely so that we can support more kinds of errors in the future. Going to close this for now but we are tracking the issue internally. Also either of you can open a public issue if you want it tracked more publicly. |
|
Is it possible to merge the latest version into this PR? |
|
@ArchimedesTrajano If you mean my branch, I did. But you should follow Brandon’s advice, or just wait and follow what Stephen suggested. Also, please fork it and maintain the code yourself. I don’t plan to keep this around. |
Summary
Expose a public recovery action for
SyncEngine.SharingErrorwithout making the error type itself public.This allows callers to determine when a sharing operation can be recovered by starting the sync engine or sending pending changes and retrying.
Usage
For example, a sharing operation can use the recovery action to synchronize the engine and retry when possible:
Motivation
Following the recent thread on the sqlite-data Slack channel, it turns out that
SharingErroris currently private, but some of its errors provide actionable recovery guidance in theirdebugDescription.For example,
.recordMetadataNotFoundexplicitly suggests callingsendChanges()to force synchronization:sqlite-data/Sources/SQLiteData/CloudKit/CloudKitSharing.swift
Lines 138 to 143 in f6bd67a
Without a public recovery API, callers cannot reliably identify this condition and perform the suggested recovery.
This change exposes the recovery contract while keeping the underlying
SharingErrorand its internal reasons private.Changes
SyncEngine.SharingErrorRecoveryAction.SyncEngine.RecoverableSharingErrorto expose recovery actions without exposingSharingError..startAndRetryfor.syncEngineNotRunning..sendChangesAndRetryfor.recordMetadataNotFound.