Handle errors#
Every error calendaring-sync raises on purpose derives from CalendaringSyncError, and the error reference says what each one means. A step of a sync that fails changes nothing, so you can always sync again, as Guarantees and limits lists.
from calendaring_sync import ScopeGoneError, StaleChangeSetError, StoreBusyError
unsent = []
try:
adapter.sync()
except (StoreBusyError, StaleChangeSetError):
pass # Nothing changed; sync again later.
except ScopeGoneError:
dropped = replica.drop_scope(adapter.scope_id)
unsent = [record.edit.content for record in dropped.pending + dropped.conflicts if record.edit]
Errors from the client library, such as a refused login, reach you unchanged, and each adapter’s class description names them. A server refusing one edit isn’t among them: that edit becomes a conflict, as Resolve conflicts explains.