fix: report actual failed item error in bulk seeding exception
This commit is contained in:
parent
2706ed6be0
commit
6bcd2becd5
|
|
@ -14,6 +14,7 @@ namespace Blomstra\Search\Jobs;
|
||||||
|
|
||||||
use Blomstra\Search\Exceptions\SeedingException;
|
use Blomstra\Search\Exceptions\SeedingException;
|
||||||
use Elasticsearch\Client;
|
use Elasticsearch\Client;
|
||||||
|
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
|
@ -50,10 +51,11 @@ class UpdateSearchJob extends Job
|
||||||
|
|
||||||
$items = Arr::get($response, 'items');
|
$items = Arr::get($response, 'items');
|
||||||
|
|
||||||
$error = Arr::get(Arr::first($items), 'index.error.reason');
|
$failed = array_filter($items, fn ($item) => isset($item['index']['error']));
|
||||||
|
$error = Arr::get(Arr::first($failed), 'index.error.reason', 'unknown error');
|
||||||
|
|
||||||
throw new SeedingException(
|
throw new SeedingException(
|
||||||
"Failed to seed: $error",
|
"Failed to seed: $error (" . count($failed) . '/' . count($items) . ' items failed)',
|
||||||
$items
|
$items
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue