CloudKit: how to simulate errors

Hi,

I want to simulate some error conditions to test my error-handling code, but not having an easy time doing so. Specifically I wanted to check networking issues like CKErrorZoneBusy, CKErrorNetworkFailure, CKErrorNetworkUnavailable etc and see if they have a value for CKErrorRetryAfterKey, so I can retry the operation.


This is for a Mac app which connects to CloudKit. I've installed Network Link Conditioner and enabled it, changing the network profile to various values, but rarely get an error. Only at 100% loss did I get a CKErrorNetworkFailure, but in that case, there was no value in RetryAfterKey.


How should I go about trying to reproduce these errors? Is there some setting in Network Link Conditioner that would give me the results I need?

I know this is an old question, but you can test this kind of error-handling logic by temporarily adding code to throw these errors, e.g.:

throw CKError(.requestRateLimited, [CKErrorRetryAfterKey: NSNumber(value: 10)
CloudKit: how to simulate errors
 
 
Q