- if (!func(key_str, element_obj, data)) {
- BT_LOGT("User interrupted the loop: key=\"%s\", "
- "value-addr=%p, data=%p",
- key_str, element_obj, data);
- ret = BT_FUNC_STATUS_INTERRUPTED;
+ status = func(key_str, element_obj, data);
+ BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
+ if (status != BT_FUNC_STATUS_OK) {
+ if (status < 0) {
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "User function failed while iterating "
+ "map value entries: "
+ "status=%s, key=\"%s\", "
+ "value-addr=%p, data=%p",
+ bt_common_func_status_string(status),
+ key_str, element_obj, data);
+
+ if (status == BT_FUNC_STATUS_ERROR) {
+ /*
+ * User function error becomes a
+ * user error from this
+ * function's caller's
+ * perspective.
+ */
+ status = BT_FUNC_STATUS_USER_ERROR;
+ }
+ } else {
+ BT_ASSERT(status == BT_FUNC_STATUS_INTERRUPTED);
+ BT_LOGT("User interrupted the loop: status=%s, "
+ "key=\"%s\", value-addr=%p, data=%p",
+ bt_common_func_status_string(status),
+ key_str, element_obj, data);
+ }
+