Passed
Push — trunk ( 325349...f71779 )
by Christian
12:37 queued 16s
created

ElasticsearchIndexingException::indexingError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Elasticsearch\Framework\Indexing;
4
5
use Shopware\Core\Framework\HttpException;
6
use Shopware\Core\Framework\Log\Package;
7
use Shopware\Core\Framework\ShopwareHttpException;
8
use Shopware\Elasticsearch\Exception\ElasticsearchIndexingException as IndexingError;
9
use Symfony\Component\HttpFoundation\Response;
10
11
#[Package('core')]
12
class ElasticsearchIndexingException extends HttpException
13
{
14
    public const ES_DEFINITION_NOT_FOUND = 'ELASTICSEARCH_INDEXING__DEFINITION_NOT_FOUND';
15
16
    public const ES_INDEXING_ERROR = 'ELASTICSEARCH_INDEXING__INDEXING_ERROR';
17
18
    public static function definitionNotFound(string $definition): self
19
    {
20
        return new self(
21
            Response::HTTP_BAD_REQUEST,
22
            self::ES_DEFINITION_NOT_FOUND,
23
            sprintf('Elasticsearch definition of %s not found', $definition),
24
        );
25
    }
26
27
    /**
28
     * @param array{index: string, id: string, type: string, reason: string}[] $errors
29
     */
30
    public static function indexingError(array $errors): ShopwareHttpException
31
    {
32
        return new IndexingError($errors);
33
    }
34
}
35