Log clear hint for 403 (IP whitelist), 401, 429, 5xx. Commands exit with failure and print error when API returns no data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
467d85dfec
commit
7e9c43f2bf
@@ -16,6 +16,11 @@ class ShopifyMap extends Command
|
|||||||
$dryRun = $this->option('dry-run');
|
$dryRun = $this->option('dry-run');
|
||||||
$variants = $shopify->getAllVariants();
|
$variants = $shopify->getAllVariants();
|
||||||
|
|
||||||
|
if (empty($variants)) {
|
||||||
|
$this->error('Keine Varianten von Shopify erhalten — API-Aufruf fehlgeschlagen (Details im Log).');
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
$this->info('Shopify-Varianten geladen: ' . count($variants));
|
$this->info('Shopify-Varianten geladen: ' . count($variants));
|
||||||
|
|
||||||
$mapped = 0;
|
$mapped = 0;
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ class ShopifySync extends Command
|
|||||||
$dryRun = $this->option('dry-run');
|
$dryRun = $this->option('dry-run');
|
||||||
$variants = $shopify->getAllVariants();
|
$variants = $shopify->getAllVariants();
|
||||||
|
|
||||||
|
if (empty($variants)) {
|
||||||
|
$this->error('Keine Varianten von Shopify erhalten — API-Aufruf fehlgeschlagen (Details im Log).');
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
$added = 0;
|
$added = 0;
|
||||||
$removed = 0;
|
$removed = 0;
|
||||||
$inSync = 0;
|
$inSync = 0;
|
||||||
|
|||||||
@@ -31,7 +31,19 @@ class ShopifyService
|
|||||||
$response = Http::withHeader('X-Shopify-Access-Token', $this->token)->get($url);
|
$response = Http::withHeader('X-Shopify-Access-Token', $this->token)->get($url);
|
||||||
|
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
Log::error('Shopify API error', ['status' => $response->status(), 'body' => $response->body()]);
|
$status = $response->status();
|
||||||
|
$hint = match (true) {
|
||||||
|
$status === 401 => 'Access Token ungültig oder fehlt',
|
||||||
|
$status === 403 => 'IP-Whitelist: VPS-IP ist in Shopify nicht freigeschalten',
|
||||||
|
$status === 429 => 'Rate Limit überschritten',
|
||||||
|
$status >= 500 => 'Shopify-seitiger Fehler',
|
||||||
|
default => 'Unbekannter Fehler',
|
||||||
|
};
|
||||||
|
Log::error("Shopify Sync fehlgeschlagen: {$hint}", [
|
||||||
|
'status' => $status,
|
||||||
|
'url' => $url,
|
||||||
|
'body' => $response->body(),
|
||||||
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user