Get partial errors from NSError - ios

When using CloudKit, sometimes the error returned is PartialFailure, which may caused by duplicate subscriptions, etc. See example below.
<CKError 0x7f8318711520: "Partial Failure" (2/1011);
"Failed to modify some subscriptions"; uuid = A434B010-7650-4BBA-8A7A-33CD0690FD15;
container ID = "iCloud.xxx.xxx"; partial errors: {
EFC65F4A-A595-44A3-A022-323D9CE9B535 = <CKError 0x7f831a007be0: "Server Rejected Request" (15/2032); server message = "subscription is duplicate of '_930081460_AA87A676-DE57-4530-8BB8-7465BF4F4303'">
C4913907-28F3-42DB-8455-9966D9084834 = <CKError 0x7f83185cfc20: "Server Rejected Request" (15/2032); server message = "subscription is duplicate of '_930081460_F92FA91D-3E92-4E46-AE59-E912F8871026'"> }>
I wish to retrieve these partial errors from the main error object but I don't know how. NSError doesn't have a partialError property, and it neither has a key in userInfo to retrieve that.

You aren't getting back a straight NSError, you are getting back a CKError. Looking at the documentation for CKError, there is in fact a CKPartialErrorsByItemIDKey key. That looks like the key that would return a dictionary of CKErrors keyed by item ID if you ask me! The userInfo object should contain that key.
Also documented here
CloudKit Framework Constants Reference

Two years later, and I still don't think how to access partial errors is particularly well documented. Thanks to #Acey for putting me on the right path with CKPartialErrorsByItemIDKey
For those who are struggling, here is an example of how I ended up accessing a partial error in a CKModifySubscriptionsOperation (Swift 2.2):
someZoneSubscriptionOperation.modifySubscriptionsCompletionBlock = {(savedSubscriptions: [CKSubscription]?, deletedSubscriptionIDs:[String]?, operationError:NSError?) in
// check specifically for an error in changing subscriptions to custom zone with specific subscriptionID
if let partialError = operationError?.userInfo[CKPartialErrorsByItemIDKey]?[subscriptionID] as? ErrorType {
print(partialError) // prints partial error for custom zone with `subscriptionID` if it exists
}
}

Related

Not able to sign in with AWSMobileClient iOS. Getting AWSMobileClientError error 13

I'm using the AWSMobileClient on iOS for authentication and I'm not able to sign in. I'm calling the signin method and all I'm getting is the following error:
The operation couldn’t be completed. (AWSMobileClient.AWSMobileClientError error 13.)
This error is useless to me and I can't find any decent documentation on what this error means. Has anyone seen this? Appreciate your help.
Please take a look at this https://github.com/aws-amplify/aws-sdk-ios/issues/1538#issuecomment-491905913
You can cast the error as AWSMobileClientError and switch on it to exhaust the list of errors.
Alternatively, I've moved over the internal message property over to my app like this:
https://github.com/lawmicha/iOS-User-Authentication-with-Email-Facebook-Google/blob/master/AmplifyUserAuthentication1/Internal/ErrorMapper.swift
extension AWSMobileClientError {
var message: String {
switch self {
case .aliasExists(let message),
.badRequest(let message),
and then I can access the message on error after casting it to AWSMobileClientError from if let error = error as? AWSMobileClientError
You should keep in mind that the alternative method exposes the message which is a developer facing message and not a end-user facing message. Ideally when you need to provide an end-user facing message, you would use first method and map the error case to a specific localized message.

How to get token_for_business for Facebook login - iOS

How can I get token_for_business from Facebook login? I have setup a business and associated my application with that business. Facebook documentation says you need to call GET /me?fields=token_for_business on User node, and it will return following json.
{
"id": "1234567890"
"token_for_business": "weg23ro87gfewblwjef"
}
I tried by providing token_for_business in parameter list of /me call but didn't work. Need advises.
Edit
I found this URL https://developers.facebook.com/docs/graph-api/reference/v2.5/user and tried by passing token_for_business in param of initWithGraphPath but no gain. I checked in Graph API Explorer and getting the required data. But not sure how to call from my objective-C code.
Edit 2
I Inspected the error object of initWithGraphPath:#"me?fields=token_for_business" call and found following details
Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=403, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=(#200) Application must be associated with a business. https://business.facebook.com/, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=200, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 200;
"fbtrace_id" = "EN9bN/YMloA";
message = "(#200) Application must be associated with a business. https://business.facebook.com/";
type = OAuthException;
};
};
code = 403;
}}
But if I try my app in Graph API Explorer then I'm getting the required data. So now it confusing me.

iTunes Connect submit for review - Your app information could not be saved. Try again

I get this error message when trying to submit a new version of my app for review:
While I've seen other threads about this error message, the solutions presented haven't worked for me and I haven't seen any mentions of the actual server error message I get. iTunes Connect responds with the following error message:
Error converting JSON string to object: Can not instantiate value of type [simple type, class com.apple.jingle.label.content.purple.to.LCSubmitForReviewTO] from JSON integral number; no single-int-arg constructor/factory method
Request details:
Remote Address:23.1.186.88:443
Request URL:https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/123456789/version/submit/complete
Request Method:POST
Status Code:500 Internal Server Error
Full JSON response:
{
"data":null,
"messages": {
"warn":null,
"error":[
"Error converting JSON string to object: Can not instantiate value of type [simple type, class com.apple.jingle.label.content.purple.to.LCSubmitForReviewTO] from JSON integral number; no single-int-arg constructor/factory method"
],
"info":null
},
"statusCode":"ERROR"
}
I've tried clearing all cookies, and also changing to another browser, and I've also tried removing the build and adding it again, but I get the same issue regardless. Has anyone else had this exact problem? Did anyone find a way around it?
I just tried submitting my app again, after 12 hours of being unable to. It worked!

CloudKit: "There is no operation associated with this request"

When attempting to save a CloudKit CKRecord, I get a CKError returned which gives the following description:
<CKError 0x7fd3d24e1810: "Internal Error" (1/2005); "there is no operation
associated with this request">
Any ideas what might cause this? Google does not return any results at all to this error.
This error is mentioned in the CloudKit constants reference here. Clearly this is some sort of internal issue in CK. Is the issue recurring? Are you doing anything special in this operation?

How to handle errors from Quickblox iOS SDK?

I got this message from quickblox ios sdk,
{
errors = {
email = (
"has already been taken"
);
};
}
I'm not sure how to handle error with quickblox? Is there a list of error messages that I can by forget the issue? I got to print this message with help of QBResponse object like this,
NSLog(#"%#",response.error.reasons);
Here reason is a NSDictionary, how do I know which error message key is inside?
At the same time, I got this message Expected status code in (200-299), got 422 for NSLog(#"%#",response.error.error.localizedDescription);
You should check localizedRecoverySuggestion at first, if nil is there, than you should look for reasons dictionary. Unfortunately there are no standard keys that you could expect.

Resources