Ver código fonte

kintoneエラーの詳細ログ

master
sosuke.iwabuchi 2 horas atrás
pai
commit
7516345d10
1 arquivos alterados com 33 adições e 12 exclusões
  1. +33
    -12
      app/Kintone/KintoneAccess.php

+ 33
- 12
app/Kintone/KintoneAccess.php Ver arquivo

@@ -4,6 +4,7 @@ namespace App\Kintone;

use App\Exceptions\AppCommonException;
use App\Exceptions\ConfigException;
use App\Exceptions\ExclusiveException;
use App\Files\TmpFile;
use App\Kintone\Models\KintoneModel;
use Exception;
@@ -197,14 +198,6 @@ class KintoneAccess
"revision" => $model->getRevision(),
];

// logger([
// "ACTION" => "KINTONE UPDATE",
// "APP" => $this->appName,
// "RECORD_NO" => $model->getRecordId(),
// "SEND_DATA" => $sendData,
// "JSON" => json_encode($sendData, JSON_UNESCAPED_UNICODE),
// ]);

$response = Http::withHeaders([
"X-Cybozu-API-Token" => $this->apiToken,
])->put($this->getRecordUrl(), $sendData);
@@ -212,7 +205,30 @@ class KintoneAccess
if ($response->failed()) {
$e = $response->toException();
if ($e instanceof Exception) {
Log::error($e->getMessage());
$context = [
"action" => "KINTONE_UPDATE",
"appName" => $this->appName,
"appId" => $this->appId,
"recordId" => $model->getRecordId(),
"sendRevision" => $model->getRevision(),
"sendRecord" => $sendData["record"],
"status" => $response->status(),
"responseBody" => $response->body(),
];

if ($response->status() === 409) {
try {
$current = $this->find((int)$model->getRecordId());
$context["currentRevision"] = $current->getRevision();
} catch (Exception $findException) {
$context["currentRevisionError"] = $findException->getMessage();
}

Log::error(sprintf("Kintone排他エラー:%s", $e->getMessage()), $context);
throw new ExclusiveException($e->getMessage(), (int)$e->getCode(), $e);
}

Log::error($e->getMessage(), $context);
throw $e;
}
}
@@ -239,9 +255,14 @@ class KintoneAccess
if ($response->failed()) {
$e = $response->toException();
if ($e instanceof Exception) {
Log::error($e->getMessage());
Log::error($response->body());
Log::error($sendData);
Log::error($e->getMessage(), [
"action" => "KINTONE_CREATE",
"appName" => $this->appName,
"appId" => $this->appId,
"sendRecord" => $sendData["record"],
"status" => $response->status(),
"responseBody" => $response->body(),
]);
throw $e;
}
}


Carregando…
Cancelar
Salvar