I'm trying to fetch all contacts from El Capitan, and I'm using the Contacts API to do so. Here is the method where I fetch the contacts:
-(void)getAllContacts{
NSError* contactError;
//initialize the contact store
CNContactStore* addressBook = [[CNContactStore alloc]init];
//specify the fields I need
NSArray * keysToFetch =#[CNContactEmailAddressesKey, CNContactPhoneNumbersKey, [CNContactFormatter descriptorForRequiredKeysForStyle:CNContactFormatterStyleFullName]];
//establish the request with the above keys
CNContactFetchRequest * request = [[CNContactFetchRequest alloc]initWithKeysToFetch:keysToFetch];
//fetch all the contacts
BOOL success = [addressBook enumerateContactsWithFetchRequest:request error:&contactError usingBlock:^(CNContact * __nonnull contact, BOOL * __nonnull stop){
//I'm doing nothing here to try to isolate the problem, but even if I do something here, the problem remains
}];
//success is always true
//contactError is always nil
//5 or so seconds later, I see the error output to the console
}
Nothing fancy going on, but I everytime after this method executes, 5-10 seconds later the following error is output to the console:
[Accounts] Failed to update account with identifier 72360D58-3D7H-49FC-1086-QRCIEQ8A991A0, error: Error Domain=ABAddressBookErrorDomain Code=1002 "(null)"
I'm not explicitly trying to update any accounts. If I don't include the enumerateContactsWithFetchRequest call, then no error is output. I've tried this on multiple different Macs with different contact lists, and I get this same error. I am also checking that the CNContactStore authorization status is CNAuthorizationStatusAuthorized before I invoke getAllContacts.
This is really frustrating, I'm starting to suspect this might be a bug in the Contacts API? Has anyone else seen this issue, or have any idea what might be causing it? Thanks for the help!
PS. I changed the ID of the account in the error statement in case that is a security concern :)
Related
I'm trying to setup some useful error handling in a program that used ODBC. According to documentation if SQLExecDirect returns SQL_ERROR I should be able to call SQLGetDiagRec to get SQL_STATE and possibly some messages, but in my tests when I call SQLGetDiagRec right after getting an error from SQLExecDirect I get SQL_NO_DATA returned and no information.
Code:
result = SQLExecDirect(hstmt, <SQL Statement>, SQL_NTS);
if(result == SQL_ERROR)
{
SQLSMALLINT msg_len = 0;
SQLCHAR sql_state[6], message[256];
SQLINTEGER native_error = 0;
result = SQLGetDiagRec(SQL_HANDLE_DBC, hDbc, 1, sql_state, &native_error, message, countof(message), &msg_len);
// Here 'result' is SQL_NO_DATA
....
}
It works in other cases, just not for SQLExecDirect for some reason. I'm also aware that one should cycle through the SQLGetDiagRec results, but if the very first one returns SQL_NO_DATA, according to documentation it means that there are no further ones.
The specific error that I was testing it with was requesting a non-existent table.
Is there anything else that I need to do in order obtain at least an error code, or does the diagnostic not work for errors that result from incorrect SQL requests?
When you call SQLGetDiagRec, pass SQL_HANDLE_STMT and your statement handle (hstmt in your example). That should return errors associated with that specific statement.
I'm trying to add error codes to one of my project like this:
typedef enum {
FSChatErrorChatManagerInUse = 101,
FSChatErrorFailedToRetrieveHeader = 202,
FSChatErrorFailedToGetCount = 303,
} FSChatErrorCode;
Then, send:
NSError * err = [NSError errorWithDomain:#"Failed To Get Count"
code:FSChatErrorFailedToGetCount
userInfo:nil];
So when notified of an error, you can see what kind it is:
if (err.code == FSChatErrorFailedToGetCount) {
// do stuff
}
Question
Is there some sort of standard error code syntax or numbering I should follow? I'm having a hard time finding a reference.
This page has a nice discussion of this subject:
Like exit status codes, an NSError -code signals the nature of the
problem. These status codes are defined within a particular error
domain, in order to avoid overlap and confusion. These status codes
are generally defined by constants in an enum.
For example, in the NSCocoaErrorDomain, the status code for an error
caused by NSFileManager attempting to access a non-existant file is 4,
as defined by NSFileNoSuchFileError. However, 4 in NSPOSIXErrorDomain
refers to a POSIX EINTR, or "interupted function" error.
So, since you're using your own error domain, you can create whatever error codes you want. By the way, in your example you seem to be misusing the domain value: it's not meant to contain an error message.Use userInfo[NSLocalizedDescriptionKey] for that.
I try to get information from Yodlee API.
I have a test user where I've implemented adding an account and I got refresh OK from the site:
{ siteRefreshStatus: {
siteRefreshStatusId: 8
siteRefreshStatus: "REFRESH_COMPLETED_WITH_UNCERTAIN_ACCOUNT"
}
- siteRefreshMode: {
refreshModeId: 2
refreshMode: "NORMAL"
}
- updateInitTime: 0
nextUpdate: 1391603301
code: 403
noOfRetry: 0
}
}
Now when I try to perform search and get the actual transactions I get this error:
{
errorOccured: "true"
exceptionType: "com.yodlee.core.IllegalArgumentValueException"
refrenceCode: "_57c250a9-71e8-4d4b-830d-0f51a4811516"
message: "Invalid argument value: Container type cannot be null"
}
The problem is that I have container type!
Check out the parameters I send:
cobSessionToken=08062013_2%3Ad02590d4474591e507129bf6baaa58e81cd9eaacb5753e9441cd0b1ca3b8bd00a3e6b6a943956e947458307c1bb94b505e2eb4398f890040a3db8c98606c0392&userSessionToken=08062013_0%3A8e8ef9dd4f294e0f16dedf98c1794b96bf33f2e1f2686eda2f35dfe4901dd3a871eed6d08ce52c99a74deb004c025ebf4bf94c7b17baf8ba18aacb331588f5f5&transactionSearchRequest.containerType=bank&transactionSearchRequest.higherFetchLimit=1000&transactionSearchRequest.lowerFetchLimit=1&transactionSearchRequest.resultRange.endNumber=500&transactionSearchRequest.resultRange.startNumber=1&transactionSearchRequest.searchClients.clientId=1&transactionSearchRequest.searchClients.clientName=DataSearchService&transactionSearchRequest.ignoreUserInput=true&transactionSearchRequest.searchFilter.currencyCode=USD&transactionSearchRequest.searchFilter.postDateRange.fromDate=01-01-2014&transactionSearchRequest.searchFilter.postDateRange.toDate=01-31-2014&transactionSearchRequest.searchFilter+.transactionSplitType=ALL_TRANSACTION&transactionSearchRequest.searchFilter.itemAccountId+.identifier=10008425&transactionSearchRequest.searchClients=DEFAULT_SERVICE_CLIENT
There is an error occurred while adding the account, which can be interpreted by this parameter code: 403 and hence you will not be seeing that account when you call the getItemSummary API. An account is successfully linked if the code has zero as value. E.g.code:0 . 403 is an error which is show if Yodlee's data agent has encountered an unhandled use case. Hence for any such error you should file a service request using Yodlee customer care tool.
To know more about error codes please visit -
https://developer.yodlee.com/FAQs/Error_Codes
The status is show as completedsiteRefreshStatus: "REFRESH_COMPLETED_WITH_UNCERTAIN_ACCOUNT"because addition of any account is followed by a refresh in which Yodlee's data agent logs into the websites of FIs and try scraping data. Hence completion of this activity is denoted as REFRESH_COMPLETED even when there is an error occurred.
TranasctionSearch issue -
I can see two of the parameters with a "+" sign. Since transactionSlipttype and containerType are dependent on each other the error is thrown.
&transactionSearchRequest.searchFilter+.transactionSplitType=ALL_TRANSACTION
&transactionSearchRequest.searchFilter.itemAccountId+.identifier=10008425
The right parameters are -
&transactionSearchRequest.searchFilter.transactionSplitType=ALL_TRANSACTION
&transactionSearchRequest.searchFilter.itemAccountId.identifier=10008425
Oof... having an issue here..
I'm using CoreData and the root view of my navigation controller gives a list of staff.
If I click a staff member, I push the detail view of that staff member.
If I click on one of the detail fields (i.e. 'Name' or 'Location') I push an editing view controller where I can change the data and then save.
I have two different edit controllers... one for simple text edits ("EditTextController") and one for Location ("EditLocationController") which is a relationship field where you can select the location from a list.
If I create a new staff member, everything works perfectly. I'm even able to update any of the text fields or location field without error.
The problem comes when I try to UPDATE an existing staff member. I'm able to change their Location no problem... no errors. But if I try and update the textfield of an existing staff member I get a nasty error.
-[StaffListMasterViewController configureCell:atIndexPath:]: unrecognized selector sent to instance 0x6d7e650
2012-02-21 14:32:14.663 FanOut[2664:fb03] CoreData: error: Serious application error.
Exception was caught during Core Data change processing. This is usually a bug within an
observer of NSManagedObjectContextObjectsDidChangeNotification. -
[StaffListMasterViewController configureCell:atIndexPath:]: unrecognized selector sent to
instance 0x6d7e650 with userInfo (null)
2012-02-21 14:32:14.665 FanOut[2664:fb03] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[StaffListMasterViewController configureCell:atIndexPath:]: unrecognized selector sent to instance 0x6d7e650'
It's confusing because the code in the two controllers seems to be identical
- (void) saveButtonPressed:(id) sender {
[managedObject setValue:textField.text forKey:keyString];
//Save the context
NSError *error = nil;
if (![self.managedObjectContext save:&error]) {
NSLog(#"Unresolved error %#, %#", error, [error userInfo]);
abort();
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}
I don't know.. I'm certain I probably have not provided enough information to figure this out. But maybe if anyone has suggestions on what else I need to include for troubleshooting? Thanks in advance...
Show the code for this method: -[StaffListMasterViewController configureCell:atIndexPath:]. Update your question with this information, so you can get the benefit of text formatting.
I created new version of CoreData model (added one new attribute to entity) and mapping from one to another. Then I open document created with old model. It opens normally but when I tried to save it I get alert window with "The document “Blahblahblah” could not be saved as “Blahblahblah.blah”. An error occurred while saving." and message in debug console
AppKit called rmdir("/private/var/folders/v9/y2tl4yh55zj1pcg0typksyrm0000gp/T/TemporaryItems/(A Document Being Saved By Document 3)"), it didn't return 0, and errno was set to 66.
Have you got ideas what is it meen?
PS. It is not my first experience in CoreData migration but it's first time I stuck so hard.
Your mileage may vary, but when I had this issue, it turned out to be a validation error.
My use case was an autosave (i.e. I hadn't explicitly called save). I verified this by explicitly putting a save call in and dumping the resultant error:
NSError* error = nil;
if (![context save:&error]) {
NSLog(#"Unresolved error %#, %#", error, [error userInfo]);
abort();
}
Turns out (in my case), I had a required entity that wasn't being set.
Good luck.