From: Vladimir Fomichev Date: Wed, 24 Dec 2025 07:39:02 +0000 (+0300) Subject: Сохранение информации об ошибке из error_json в error_text X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=af5e687c69b65902a073d044cfba8403398b7611;p=erp24_rep%2Fyii-erp24%2F.git Сохранение информации об ошибке из error_json в error_text --- diff --git a/erp24/services/UploadService.php b/erp24/services/UploadService.php index 23f4df58..c457fb67 100644 --- a/erp24/services/UploadService.php +++ b/erp24/services/UploadService.php @@ -1497,8 +1497,32 @@ class UploadService { if (!empty($arr2["errors"]) && is_array($arr2["errors"])) { $errorDescriptions = []; foreach ($arr2["errors"] as $err) { - if (!empty($err["error_description"])) { - $errorDescriptions[] = $err["error_description"]; + $errorParts = []; + + // Обрабатываем error_json - все элементы массива + if (!empty($err["error_json"]) && is_array($err["error_json"])) { + foreach ($err["error_json"] as $errorJson) { + if (!empty($errorJson["field"]) && !empty($errorJson["error"])) { + $errorParts[] = 'Значение поля ' . $errorJson["field"] . ' с ошибкой: ' . $errorJson["error"]; + } elseif (!empty($errorJson["error"])) { + $errorParts[] = $errorJson["error"]; + } + } + } + + // Используем error_description как fallback, если нет error_json + if (empty($errorParts) && !empty($err["error_description"])) { + $errorParts[] = $err["error_description"]; + } + + // Добавляем error, если есть и еще ничего не добавлено + if (empty($errorParts) && !empty($err["error"])) { + $errorParts[] = $err["error"]; + } + + // Объединяем части ошибки для текущего элемента + if (!empty($errorParts)) { + $errorDescriptions[] = implode('; ', $errorParts); } } $errorText = implode('; ', $errorDescriptions);