int err = contacts_db_get_record(_contacts_contact._uri, contact_id,
&contacts_record);
if (CONTACTS_ERROR_NONE != err) {
- LoggerW("Contacts record get error, error code: %d", err);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
- "Contacts record get error");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
+ "Contacts record get error",
+ ("Contacts record get error, error code: %d", err));
}
ContactUtil::ContactsRecordHPtr contacts_record_ptr(
&contacts_record, ContactUtil::ContactsDeleter);
long addressBookId = common::stol(FromJson<JsonString>(args, "addressBookId"));
if (!IsNull(contact, "id")) {
- LoggerW("Contact already exists");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contact already exists");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contact already exists");
}
contacts_record_h contacts_record = nullptr;
int err = 0;
err = contacts_record_create(_contacts_contact._uri, &contacts_record);
if (CONTACTS_ERROR_NONE != err) {
- LoggerW("Contacts record create error, error code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Contacts record create error");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Contacts record create error",
+ ("Contacts record create error, error code: %d", err));
}
// contacts_record starts to be protected by unique_ptr
int id = -1;
err = contacts_db_insert_record(*contacts_record_ptr, &id);
if (CONTACTS_ERROR_NONE != err) {
- LoggerW("Contacts db insert error, error code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts db insert error");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts db insert error",
+ ("Contacts db insert error, error code: %d", err));
}
contacts_record_h reset_record;
err = contacts_db_get_record(_contacts_contact._uri, id, &reset_record);
if (CONTACTS_ERROR_NONE != err) {
- LoggerW("Contacts record get error, error code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record get error");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record get error",
+ ("Contacts record get error, error code: %d", err));
}
if (nullptr != reset_record) {
LoggerE("reset");
long contactId = common::stol(FromJson<JsonString>(contact, "id"));
if (IsNull(contact, "id")) {
- LoggerW("Contact doesn't exist");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contact doesn't exist");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contact doesn't exist");
}
contacts_record_h to_update = nullptr;
int err = contacts_db_get_record(_contacts_contact._uri, contactId, &to_update);
if (CONTACTS_ERROR_NONE != err) {
- LoggerW("Problem with getting contact. Error: %d", err);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
- "Problem with getting contact");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
+ "Problem with getting contact",
+ ("Problem with getting contact. Error: %d", err));
}
ContactUtil::ContactsRecordHPtr contacts_record_ptr(
&to_update, ContactUtil::ContactsDeleter);
err = contacts_db_update_record(*contacts_record_ptr);
if (CONTACTS_ERROR_NONE != err) {
if (CONTACTS_ERROR_INVALID_PARAMETER == err) {
- LoggerE("Error during executing contacts_db_update_record(). Error: %d",
- err);
- return PlatformResult(
+ return LogAndCreateResult(
ErrorCode::NOT_FOUND_ERR,
- "Error during executing contacts_db_update_record().");
+ "Error during executing contacts_db_update_record().",
+ ("Error during executing contacts_db_update_record(). Error: %d", err));
}
if (CONTACTS_ERROR_DB == err) {
- LoggerE("Error during executing contacts_db_update_record(). Error: %d",
- err);
- return PlatformResult(
+ return LogAndCreateResult(
ErrorCode::UNKNOWN_ERR,
- "Error during executing contacts_db_update_record().");
+ "Error during executing contacts_db_update_record().",
+ ("Error during executing contacts_db_update_record(). Error: %d", err));
}
}
int contact_id = common::stol(FromJson<JsonString>(args, "id"));
if (contact_id < 0) {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Nagative contact id");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Nagative contact id");
}
int err = contacts_db_delete_record(_contacts_contact._uri, contact_id);
if (CONTACTS_ERROR_NO_DATA == err) {
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
"Remove failed: contact not found");
} else if (CONTACTS_ERROR_NONE != err) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Contacts record delete error");
}
contacts_list_h contacts_list = NULL;
int error_code = contacts_list_create(&contacts_list);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("list creation failed, code: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "list creation failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "list creation failed",
+ ("list creation failed, code: %d", error_code));
}
ContactUtil::ContactsListHPtr contacts_list_ptr(
&contacts_list, ContactUtil::ContactsListDeleter);
int err = 0;
err = contacts_record_create(_contacts_contact._uri, &contacts_record);
if (CONTACTS_ERROR_NONE != err) {
- LoggerW("Contacts record create error, error code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Contacts record create error");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Contacts record create error",
+ ("Contacts record create error, error code: %d", err));
}
ContactUtil::ContactsRecordHPtr x(&contacts_record,
ContactUtil::ContactsDeleter);
error_code = contacts_list_add(*contacts_list_ptr, *(x.release()));
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("error during add record to list, code: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "error during add record to list");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "error during add record to list",
+ ("error during add record to list, code: %d", error_code));
}
}
error_code = contacts_db_insert_records(*contacts_list_ptr, &ids, &count);
if (CONTACTS_ERROR_NONE != error_code || nullptr == ids) {
- LoggerE("inserting contacts to db fails, code: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "inserting contacts to db fails");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "inserting contacts to db fails",
+ ("inserting contacts to db fails, code: %d", error_code));
}
if (length != count) {
error_code =
contacts_db_get_record(_contacts_contact._uri, ids[i], &contact_record);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerW("Contacts record get error, error code: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Contacts record get error");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Contacts record get error",
+ ("Contacts record get error, error code: %d", error_code));
}
status = ContactUtil::ImportContactFromContactsRecord(
contact_record, &out_object);
int err = 0;
err = contacts_list_create(&contacts_list);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("list creation failed, code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "list creation failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "list creation failed",
+ ("list creation failed, code: %d", err));
}
ContactUtil::ContactsListHPtr contacts_list_ptr(
&contacts_list, ContactUtil::ContactsListDeleter);
const JsonObject& contact = JsonCast<JsonObject>(item);
long contactId = common::stol(FromJson<JsonString>(contact, "id"));
if (IsNull(contact, "id")) {
- LoggerW("Contact doesn't exist");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contact doesn't exist");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contact doesn't exist",
+ ("Contact doesn't exist"));
}
contacts_record_h to_update = nullptr;
err = contacts_db_get_record(_contacts_contact._uri, contactId, &to_update);
if (CONTACTS_ERROR_NONE != err) {
- LoggerW("Problem with getting contact. Error: %d", err);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
- "Problem with getting contact");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
+ "Problem with getting contact",
+ ("Problem with getting contact. Error: %d", err));
}
ContactUtil::ContactsRecordHPtr x(&to_update,
ContactUtil::ContactsDeleter);
err = contacts_list_add(*contacts_list_ptr, *(x.release()));
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("error during add record to list, code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "error during add record to list");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "error during add record to list",
+ ("error during add record to list, code: %d", err));
}
}
err = contacts_db_update_records(*contacts_list_ptr);
if (CONTACTS_ERROR_NONE != err) {
if (CONTACTS_ERROR_INVALID_PARAMETER == err) {
- LoggerE("Error during executing contacts_db_update_record(). Error: %d",
- err);
- return PlatformResult(
+ return LogAndCreateResult(
ErrorCode::NOT_FOUND_ERR,
- "Error during executing contacts_db_update_record().");
+ "Error during executing contacts_db_update_record().",
+ ("Error during executing contacts_db_update_record(). Error: %d",
+ err));
}
if (CONTACTS_ERROR_DB == err) {
- LoggerE("Error during executing contacts_db_update_record(). Error: %d",
- err);
- return PlatformResult(
+ return LogAndCreateResult(
ErrorCode::UNKNOWN_ERR,
- "Error during executing contacts_db_update_record().");
+ "Error during executing contacts_db_update_record().",
+ ("Error during executing contacts_db_update_record(). Error: %d",
+ err));
}
}
return PlatformResult(ErrorCode::NO_ERROR);
for (auto& item : batch_args) {
long contact_id = common::stol(item.get<std::string>());
if (contact_id < 0) {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Nagative contact id");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Nagative contact id");
}
ids[i] = contact_id;
i++;
}
int err = contacts_db_delete_records(_contacts_contact._uri, ids, length);
if (CONTACTS_ERROR_NO_DATA == err) {
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
"Remove failed: contact not found");
} else if (CONTACTS_ERROR_NONE != err) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Contacts record delete error");
}
return PlatformResult(ErrorCode::NO_ERROR);
const JsonObject& group = FromJson<JsonObject>(args, "group");
if (!IsNull(group, "id") || !IsNull(group, "addressBookId")) {
- LoggerE("Group object is previously added");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
"Group object is previously added");
}
long id = common::stol(FromJson<JsonString>(args, "id"));
if (id < 0) {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Incorrect group id");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Incorrect group id");
}
contacts_record_h contacts_record = nullptr;
int err = contacts_db_get_record(_contacts_group._uri, id, &contacts_record);
if (CONTACTS_ERROR_NONE != err || nullptr == contacts_record) {
- LoggerE("Group not exist");
- return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Group not exist");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Group not exist");
}
ContactUtil::ContactsRecordHPtr record(&contacts_record,
if (status.IsError()) return status;
if (address_book_id != addressbook_id) {
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
"No group in this address book.");
}
}
const JsonObject& group = FromJson<JsonObject>(args, "group");
if (IsNull(group, "id") || IsNull(group, "addressBookId")) {
- LoggerE("Group object is not added");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
"Group object is not added");
}
long group_addressbook_id =
common::stol(FromJson<JsonString>(group, "addressBookId"));
if (IsUnified(addressbook_id) && (addressbook_id != group_addressbook_id)) {
- LoggerE("Wrong address book");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Wrong address book");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Wrong address book");
}
if (FromJson<bool>(group, "readOnly")) {
- LoggerW("Group is readonly - cancel update");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Group is readonly - cancel update");
}
long group_id = common::stol(FromJson<JsonString>(group, "id"));
if (group_id < 0) {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Incorrect group id");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Incorrect group id");
}
contacts_record_h contacts_record = nullptr;
int err =
contacts_db_get_record(_contacts_group._uri, group_id, &contacts_record);
if (CONTACTS_ERROR_NONE != err || nullptr == contacts_record) {
- LoggerE("Group not exist");
- return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Group not exist");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Group not exist");
}
status = ContactUtil::ErrorChecker(
err = contacts_db_update_record(contacts_record);
if (CONTACTS_ERROR_INVALID_PARAMETER == err) {
- LoggerE("Problem during db_update_record");
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
"Problem during db_update_record");
}
status = ContactUtil::ErrorChecker(err, "Problem during db_update_record");
long id = common::stol(FromJson<JsonString>(args, "id"));
if (id < 0) {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Incorrect group id");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Incorrect group id");
}
int err;
contacts_record_h contacts_record = nullptr;
err = contacts_db_get_record(_contacts_group._uri, id, &contacts_record);
if (CONTACTS_ERROR_NONE != err || contacts_record == nullptr) {
- return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Group not exist");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Group not exist");
}
int group_addressbook_id = 0;
if (status.IsError()) return status;
if (group_addressbook_id != addressbook_id) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Contact is not a member of this address book");
}
}
err = contacts_db_delete_record(_contacts_group._uri, id);
if (CONTACTS_ERROR_INVALID_PARAMETER == err) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Problem during db_delete_record");
}
status = ContactUtil::ErrorChecker(err, "Problem during db_delete_record");
contacts_record_h contacts_record;
err = contacts_list_get_current_record_p(groups_list, &contacts_record);
if (CONTACTS_ERROR_NONE != err || nullptr == contacts_record) {
- LoggerE("Fail to get group record");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Fail to get group record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get group record");
}
JsonValue group{JsonObject{}};
AddressBookListenerCallback, &instance);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("Error while registering listener to contacts db, code: %d",
- error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while registering listener to contacts db");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error while registering listener to contacts db",
+ ("Error while registering listener to contacts db, code: %d",
+ error_code));
}
instance.set_is_listening(true);
_contacts_contact._uri, AddressBookListenerCallback, &instance);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("Error while removing listener");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Error while removing listener");
}
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookAdd(const JsonValue& args, JsonObject& out) {
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookAddBatch(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(result, response->get<JsonObject>());
else
- ReportError(status, &response->get<JsonObject>());
+ LogAndReportError(status, &response->get<JsonObject>());
};
auto get_response =
if (status.IsSuccess())
ReportSuccess(response->get<JsonObject>());
else
- ReportError(status, &response->get<JsonObject>());
+ LogAndReportError(status, &response->get<JsonObject>());
};
auto get_response =
if (status.IsSuccess())
ReportSuccess(result, response->get<JsonObject>());
else
- ReportError(status, &response->get<JsonObject>());
+ LogAndReportError(status, &response->get<JsonObject>());
};
auto get_response =
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookRemove(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookFind(const JsonValue& args, JsonObject& out) {
if (status.IsSuccess())
ReportSuccess(result, response->get<JsonObject>());
else
- ReportError(status, &response->get<JsonObject>());
+ LogAndReportError(status, &response->get<JsonObject>());
};
auto get_response =
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookGetGroup(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookUpdateGroup(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookRemoveGroup(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookGetGroups(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerGetAddressBooks(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(result, response->get<JsonObject>());
else
- ReportError(status, &response->get<JsonObject>());
+ LogAndReportError(status, &response->get<JsonObject>());
};
auto get_response =
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerAddAddressBook(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerRemoveAddressBook(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookStartListening(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::AddressBookStopListening(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerGet(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerUpdate(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerUpdateBatch(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(response->get<JsonObject>());
else
- ReportError(status, &response->get<JsonObject>());
+ LogAndReportError(status, &response->get<JsonObject>());
};
auto get_response =
if (status.IsSuccess())
ReportSuccess(out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerRemoveBatch(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(response->get<JsonObject>());
else
- ReportError(status, &response->get<JsonObject>());
+ LogAndReportError(status, &response->get<JsonObject>());
};
auto get_response =
if (status.IsSuccess()) {
ReportSuccess(result, response->get<JsonObject>());
} else {
- ReportError(status, &response->get<JsonObject>());
+ LogAndReportError(status, &response->get<JsonObject>());
}
};
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerStartListening(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::ContactManagerStopListening(const JsonValue& args,
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::PersonLink(const JsonValue& args, JsonObject& out) {
if (status.IsSuccess())
ReportSuccess(out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
void ContactInstance::PersonUnlink(const JsonValue& args, JsonObject& out) {
if (status.IsSuccess())
ReportSuccess(val, out);
else
- ReportError(status, &out);
+ LogAndReportError(status, &out);
}
} // namespace contact
int error_code = contacts_db_get_all_records(_contacts_address_book._uri, 0,
0, &address_book_list);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("Fail to get address book list, error: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Fail to get address book list");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Fail to get address book list",
+ ("Fail to get address book list, error: %d", error_code));
}
ContactUtil::ContactsListHPtr contacts_list_ptr(
int record_count = 0;
error_code = contacts_list_get_count(*contacts_list_ptr, &record_count);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("Fail to get address book list count, error: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Fail to get address book list count");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Fail to get address book list count",
+ ("Fail to get address book list count, error: %d", error_code));
}
error_code = contacts_list_first(*contacts_list_ptr);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("Fail to get address book from list, error: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Fail to get address book from list");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Fail to get address book from list",
+ ("Fail to get address book from list, error: %d", error_code));
}
for (int i = 0; i < record_count; i++) {
static_cast<int>(address_book_id),
&contacts_record);
if (CONTACTS_ERROR_NONE != error_code || nullptr == contacts_record) {
- LoggerE("Fail to get addressbook record, error code: %d", error_code);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
- "Fail to get address book with given id");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
+ "Fail to get address book with given id",
+ ("Fail to get addressbook record, error code: %d", error_code));
}
ContactUtil::ContactsRecordHPtr contacts_record_ptr(
int error_code = contacts_db_get_record(_contacts_person._uri, person_id,
&contacts_record);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("Person with id: %d, not found, error: %d", person_id, error_code);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Person not found");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Person not found",
+ ("Person with id: %d, not found, error: %d", person_id, error_code));
}
ContactUtil::ContactsRecordHPtr contacts_record_ptr(
const JsonObject& addressBook = FromJson<JsonObject>(args, "addressBook");
if (!IsNull(addressBook, "id")) {
- LoggerW("AddressBook already exists");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "AddressBook already exists");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "AddressBook already exists");
}
contacts_record_h contacts_record;
int ret =
contacts_record_create(_contacts_address_book._uri, &contacts_record);
if (CONTACTS_ERROR_NONE != ret) {
- LoggerE("Failed to create address book record, error code : %d", ret);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to create address book record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to create address book record",
+ ("Failed to create address book record, error code : %d", ret));
}
ContactUtil::ContactsRecordHPtr contacts_record_ptr(
&contacts_record, ContactUtil::ContactsDeleter);
int address_book_id;
ret = contacts_db_insert_record(*contacts_record_ptr, &address_book_id);
if (CONTACTS_ERROR_NONE != ret) {
- LoggerE("Failed to insert address book record, error code: %d", ret);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to insert address book record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to insert address book record",
+ ("Failed to insert address book record, error code: %d", ret));
}
out["id"] = picojson::value(std::to_string(address_book_id));
static_cast<int>(address_book_id),
&contacts_record);
if (CONTACTS_ERROR_NONE != error_code || nullptr == contacts_record) {
- LoggerE("Fail to get addressbook record, error code: %d", error_code);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
- "Fail to get address book with given id");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
+ "Fail to get address book with given id",
+ ("Fail to get addressbook record, error code: %d", error_code));
}
int ret = contacts_db_delete_record(_contacts_address_book._uri,
static_cast<int>(address_book_id));
if (CONTACTS_ERROR_NONE != ret) {
- LOGE("Failed to delete address book record, error code : %d", ret);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to delete address book record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to delete address book record",
+ ("Failed to delete address book record, error code : %d", ret));
}
return PlatformResult(ErrorCode::NO_ERROR);
&contacts_record);
if (CONTACTS_ERROR_NONE != error_code) {
- return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Person not found");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Person not found");
}
status = ContactUtil::ExportPersonToContactsRecord(contacts_record, person);
error_code = contacts_db_update_record(*contacts_record_ptr);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("error code: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error during executing contacts_db_update_record()");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error during executing contacts_db_update_record()",
+ ("error code: %d", error_code));
}
return PlatformResult(ErrorCode::NO_ERROR);
int err = 0;
err = contacts_list_create(&contacts_list);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("list creation failed, code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "list creation failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "list creation failed",
+ ("list creation failed, code: %d", err));
}
ContactUtil::ContactsListHPtr contacts_list_ptr(
&contacts_list, ContactUtil::ContactsListDeleter);
contacts_record_h to_update = nullptr;
err = contacts_db_get_record(_contacts_person._uri, personId, &to_update);
if (CONTACTS_ERROR_NONE != err) {
- return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Person not found");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Person not found");
}
ContactUtil::ContactsRecordHPtr x(&to_update,
ContactUtil::ContactsDeleter);
err = contacts_list_add(*contacts_list_ptr, *(x.release()));
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("error during add record to list, code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "error during add record to list");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "error during add record to list",
+ ("error during add record to list, code: %d", err));
}
}
err = contacts_db_update_records(*contacts_list_ptr);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("error code: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error during executing contacts_db_update_record()");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error during executing contacts_db_update_record()",
+ ("error code: %d", err));
}
return PlatformResult(ErrorCode::NO_ERROR);
long person_id = common::stol(FromJson<JsonString>(args, "personId"));
if (person_id < 0) {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Negative person id");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Negative person id");
}
int error_code = contacts_db_delete_record(_contacts_person._uri, person_id);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("Error during removing contact, error: %d", error_code);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
- "Error during removing contact");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
+ "Error during removing contact",
+ ("Error during removing contact, error: %d", error_code));
}
return PlatformResult(ErrorCode::NO_ERROR);
for (auto& item : batch_args) {
long person_id = common::stol(item.get<std::string>());
if (person_id < 0) {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Nagative contact id");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Nagative contact id");
}
ids[i] = person_id;
i++;
int err = contacts_db_delete_records(_contacts_person._uri, ids, length);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("Error during removing contact, error: %d", err);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR,
- "Error during removing contact");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
+ "Error during removing contact",
+ ("Error during removing contact, error: %d", err));
}
return PlatformResult(ErrorCode::NO_ERROR);
value = common::stol(JsonCast<std::string>(match_value));
}
if (value < 0) {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
"Match value cannot be less than 0");
}
contacts_match_int_flag_e flag;
"Failed contacts_filter_add_str");
if (status.IsError()) return status;
} else {
- LoggerE("Invalid primitive type!");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Invalid primitive type!");
}
intermediate_filters[intermediate_filters.size() - 1].push_back(
if (status.IsError()) return status;
}
} else {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Invalid primitive type!");
}
intermediate_filters[intermediate_filters.size() - 1].push_back(
visitor.SetOnCompositeFilterEnd([&](CompositeFilterType type) {
if (intermediate_filters.size() == 0) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Reached stack size equal to 0!");
}
error_code, "Failed contacts_query_set_filter");
if (status.IsError()) return status;
} else {
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
"Invalid union type!");
}
}
// Should compute only one filter always.
if ((intermediate_filters.size() != 1) ||
(intermediate_filters[0].size() != 1)) {
- LoggerE("Bad filter evaluation!");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Bad filter evaluation!");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Bad filter evaluation!");
}
// Filter is generated
error_code = contacts_query_set_filter(contacts_query,
const auto sort_mode_it = args.find("sortMode");
if (args.end() != sort_mode_it) {
if (!sort_mode_it->second.is<picojson::object>()) {
- LoggerD("Failed to set sort mode.");
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Failed to set sort mode");
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR, "Failed to set sort mode");
}
const auto sort_mode = sort_mode_it->second;
std::string attribute = sort_mode.get("attributeName").to_str();
int err = contacts_vcard_parse_to_contacts(vcard_char_ptr, &contacts_list);
if (CONTACTS_ERROR_INVALID_PARAMETER == err) {
- LoggerE("Invalid vCard string");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Invalid vCard string");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Invalid vCard string");
} else if (CONTACTS_ERROR_NONE != err) {
- LoggerE("Fail to convert vCard from string");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Fail to convert vCard from string");
}
int record_count = 0;
err = contacts_list_get_count(contacts_list, &record_count);
if (CONTACTS_ERROR_NONE != err || 0 == record_count) {
- LoggerE("Invalid vCard string.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Invalid vCard string.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Invalid vCard string.");
}
contacts_record_h contacts_record;
contacts_list_first(contacts_list);
err = contacts_list_get_current_record_p(contacts_list, &contacts_record);
if (CONTACTS_ERROR_NONE != err || nullptr == contacts_record) {
- LoggerE("Invalid vCard string.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Invalid vCard string.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Invalid vCard string.");
}
status = ContactUtil::ImportContactFromContactsRecord(contacts_record, &out);
_contacts_person._uri, ContactManagerListenerCallback, &instance);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("contacts_db_add_changed_cb(_contacts_person._uri) error: %d",
- error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to start listening");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to start listening",
+ ("contacts_db_add_changed_cb(_contacts_person._uri) error: %d",
+ error_code));
}
return PlatformResult(ErrorCode::NO_ERROR);
_contacts_person._uri, ContactManagerListenerCallback, &instance);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("contacts_db_remove_changed_cb(_contacts_person._uri) error: %d",
- error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to stop listening");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to stop listening",
+ ("contacts_db_remove_changed_cb(_contacts_person._uri) error: %d",
+ error_code));
}
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Entered");
if (!filter.is<picojson::object>()) {
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Failed to set filter");
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR, "Failed to set filter");
}
common::FilterVisitor visitor;
LoggerD("Entered");
if (!sort_mode.is<picojson::object>()) {
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Failed to set sort mode");
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR, "Failed to set sort mode");
}
std::string attribute = sort_mode.get("attributeName").to_str();
const auto iter = s_properties_map_.find(attribute);
if (s_properties_map_.end() == iter) {
std::string msg = "SortMode doesn't support attribute: " + attribute;
- LoggerE("%s", msg.c_str());
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, msg);
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR, msg);
}
is_sort_mode_set_ = true;
const auto iter = s_properties_map_.find(name);
if (s_properties_map_.end() == iter) {
std::string msg = "Unknown attribute name: " + name;
- LoggerE("%s", msg.c_str());
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, msg);
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR, msg);
}
const auto& properties = iter->second;
const auto iter = s_properties_map_.find(name);
if (s_properties_map_.end() == iter) {
std::string msg = "Unknown attribute name: " + name;
- LoggerE("%s", msg.c_str());
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, msg);
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR, msg);
}
LongSetPtr id_set = LongSetPtr(new LongSet());
PlatformResult ErrorChecker(int err, const char* message) {
LoggerD("Enter");
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("%s, error code: %i", message, err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, message);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, message);
}
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Enter");
int err = contacts_record_get_str_p(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("Error during getting contact record, error code: %i", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error during getting contact record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error during getting contact record",
+ ("Error during getting contact record, error code: %i", err));
}
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Enter");
int err = contacts_record_get_int(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("Error during getting contact record, error code: %i", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error during getting contact record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error during getting contact record",
+ ("Error during getting contact record, error code: %i", err));
}
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Enter");
int err = contacts_record_get_bool(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("Error during getting contact record, error code: %i", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error during getting contact record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error during getting contact record",
+ ("Error during getting contact record, error code: %i", err));
}
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Enter");
int err = contacts_record_set_str(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("Error during setting str contact record property, error code: %i",
- err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error during setting contact record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error during setting contact record",
+ ("Error during setting str contact record property, error code: %i", err));
}
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Enter");
int err = contacts_record_set_int(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("Error during getting contact record, error code: %i", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error during setting contact record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error during setting contact record",
+ ("Error during getting contact record, error code: %i", err));
}
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Enter");
int err = contacts_record_set_bool(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
- LoggerE("Error during getting contact record, error code: %i", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error during setting contact record");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error during setting contact record",
+ ("Error during getting contact record, error code: %i", err));
}
return PlatformResult(ErrorCode::NO_ERROR);
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int record_count;
int err = contacts_record_get_child_record_count(contacts_record, property_id,
child_count);
if (CONTACTS_ERROR_NONE != err && CONTACTS_ERROR_NO_DATA != err) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Problem during getting child count");
}
LoggerD("Enter");
JsonObject& out = *out_ptr;
if (!contacts_record) {
- LoggerW("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int count = 0;
int err = contacts_record_get_child_record_count(contacts_record,
}
if (count > 1) {
- LoggerE("More than one ContactName for one Contact");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"More than one ContactName for one Contact");
}
LoggerD("Contact name record count: %i", count);
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerW("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h contact_name = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int err = contacts_record_create(_contacts_email._uri, &c_email_record_h);
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int err = contacts_record_get_child_record_at_p(
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int err = contacts_record_create(_contacts_number._uri, &phone_record);
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h organization_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
if (IsNull(in, "url")) {
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int date = static_cast<int>(FromJson<double>(in, "date"));
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h address_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
contacts_record_h notes_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int err = contacts_record_create(_contacts_note._uri, ¬es_record);
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int id = 0;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerW("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
//### ContactName: ###
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerE("Contacts record is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
// id
PlatformResult ImportPersonFromContactsRecord(contacts_record_h record,
JsonObject* out_ptr) {
if (nullptr == record) {
- LoggerW("Platform person record did not set");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
"Platform person record did not set");
}
PlatformResult ExportPersonToContactsRecord(contacts_record_h record,
const JsonObject& args) {
if (nullptr == record) {
- LoggerE("Platform person object did not set");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Platform person object did not set");
}
LoggerI("Connection established!");
_connected = true;
} else {
- LoggerE("DB connection error occured: %s", std::to_string(err).c_str());
- return PlatformResult(
+ return LogAndCreateResult(
ErrorCode::UNKNOWN_ERR,
"DB connection error occured: " + std::to_string(err));
}
contacts_record = nullptr;
if (CONTACTS_ERROR_NONE != err) {
- LoggerW("Person was not found, error code: %d", err);
- return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Person not found");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Person not found",
+ ("Person was not found, error code: %d", err));
}
err = contacts_person_link_person(person_id, id);
if (CONTACTS_ERROR_NONE != error_code) {
contacts_record_destroy(contacts_record, true);
contacts_record = nullptr;
- LoggerW("Contact not found, error code: %d", error_code);
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Contact not found");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Contact not found",
+ ("Contact not found, error code: %d", error_code));
}
int contacts_person_id = 0;
long person_id = common::stol(FromJson<JsonString>(args, "personId"));
if (contacts_person_id != person_id) {
- LoggerW("Contact is not a member of person (wrong id's)");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
- "Contact is not a member of person");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
+ "Contact is not a member of person",
+ ("Contact is not a member of person (wrong id's)"));
}
int new_person_id = 0;
if (CONTACTS_ERROR_NONE != error_code) {
contacts_record_destroy(contacts_record, true);
contacts_record = nullptr;
- LoggerW("Person not found, error code: %d", error_code);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Person not found");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Person not found",
+ ("Person not found, error code: %d", error_code));
}
status = ContactUtil::ImportPersonFromContactsRecord(contacts_record, &out);
LoggerD("Enter");
auto iter = personPropertyMap.find(name);
if (iter == personPropertyMap.end()) {
- LoggerE("Invalid property name (not in map): %s", name.c_str());
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
- "Invalid property name");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
+ "Invalid property name",
+ ("Invalid property name (not in map): %s", name.c_str()));
}
(*person_prop).propertyId = iter->second.propertyId;
(*person_prop).type = iter->second.type;