Skip to content

Commit

Permalink
!!![TASK:BP:11.6] Introduce specific EXT:solr exceptions
Browse files Browse the repository at this point in the history
Existing exceptions are now based on the recently introduced
generic EXT:solr exception.

Additionally based on the new generic EXT:solr exception a further
exception is introduced, allowing more targeted handling of exceptions:
InvalidIndexQueueInitizalizationPostProcessorException

This is a breaking change as the base excepion changed and the new
exception is no longer based on \UnexpectedValueException.

Ports: #3764
Resolves: #3763
  • Loading branch information
dkd-friedrich authored and dkd-kaehm committed Nov 8, 2023
1 parent cdeaaff commit db3f169
Show file tree
Hide file tree
Showing 72 changed files with 188 additions and 80 deletions.
4 changes: 3 additions & 1 deletion Classes/Access/RootlineElementFormatException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

namespace ApacheSolrForTypo3\Solr\Access;

use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;

/**
* Signals a wrong format for the access definition of a page or the content.
*
* @author Ingo Renner <[email protected]>
*/
class RootlineElementFormatException extends \InvalidArgumentException
class RootlineElementFormatException extends InvalidArgumentException
{
}
2 changes: 1 addition & 1 deletion Classes/ConnectionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

use ApacheSolrForTypo3\Solr\Domain\Site\Site;
use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository as PagesRepositoryAtExtSolr;
use ApacheSolrForTypo3\Solr\System\Records\SystemLanguage\SystemLanguageRepository;
use ApacheSolrForTypo3\Solr\System\Solr\Node;
use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection;
use ApacheSolrForTypo3\Solr\System\Util\SiteUtility;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use InvalidArgumentException;
use function json_encode;
use Throwable;
use TYPO3\CMS\Core\SingletonInterface;
Expand Down
2 changes: 1 addition & 1 deletion Classes/ContentObject/Classification.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use ApacheSolrForTypo3\Solr\Domain\Index\Classification\Classification as ClassificationItem;
use ApacheSolrForTypo3\Solr\Domain\Index\Classification\ClassificationService;
use InvalidArgumentException;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
use ApacheSolrForTypo3\Solr\ConnectionManager;
use ApacheSolrForTypo3\Solr\Domain\Site\Site;
use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\IndexQueue\Queue;
use ApacheSolrForTypo3\Solr\IndexQueue\QueueInterface;
use ApacheSolrForTypo3\Solr\System\Mvc\Backend\Service\ModuleDataStorageService;
use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection as SolrCoreConnection;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use InvalidArgumentException;
use Psr\Http\Message\ResponseInterface;
use Throwable;
use TYPO3\CMS\Backend\Template\Components\Menu\Menu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
namespace ApacheSolrForTypo3\Solr\Domain\Index\Queue\GarbageRemover;

use ApacheSolrForTypo3\Solr\ConnectionManager;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\GarbageCollectorPostProcessor;
use ApacheSolrForTypo3\Solr\IndexQueue\Queue;
use ApacheSolrForTypo3\Solr\IndexQueue\QueueInterface;
use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager;
use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection;
use InvalidArgumentException;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down
10 changes: 7 additions & 3 deletions Classes/Domain/Index/Queue/QueueInitializationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
namespace ApacheSolrForTypo3\Solr\Domain\Index\Queue;

use ApacheSolrForTypo3\Solr\Domain\Site\Site;
use ApacheSolrForTypo3\Solr\Exception\Index\Queue\InvalidIndexQueueInitizalizationPostProcessorException;
use ApacheSolrForTypo3\Solr\IndexQueue\InitializationPostProcessor;
use ApacheSolrForTypo3\Solr\IndexQueue\Initializer\AbstractInitializer;
use ApacheSolrForTypo3\Solr\IndexQueue\QueueInitializationServiceAwareInterface;
use ApacheSolrForTypo3\Solr\IndexQueue\QueueInterface;
use Doctrine\DBAL\ConnectionException;
use Doctrine\DBAL\Exception as DBALException;
use Throwable;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use UnexpectedValueException;
use ApacheSolrForTypo3\Solr\IndexQueue\QueueInitializationServiceAwareInterface;

/**
* The queue initialization service is responsible to run the initialization of the index queue for a combination of sites
Expand Down Expand Up @@ -96,6 +96,7 @@ public function initializeBySitesAndConfigurations(array $sites, array $indexing
* @throws ConnectionException
* @throws Throwable
* @throws DBALException
* @throws InvalidIndexQueueInitizalizationPostProcessorException
*/
public function initializeBySiteAndIndexConfigurations(Site $site, array $indexingConfigurationNames): array
{
Expand All @@ -116,7 +117,10 @@ public function initializeBySiteAndIndexConfigurations(Site $site, array $indexi
if ($indexQueueInitializationPostProcessor instanceof InitializationPostProcessor) {
$indexQueueInitializationPostProcessor->postProcessIndexQueueInitialization($site, $indexingConfigurationNames, $initializationStatus);
} else {
throw new UnexpectedValueException(get_class($indexQueueInitializationPostProcessor) . ' must implement interface ' . InitializationPostProcessor::class, 1345815561);
throw new InvalidIndexQueueInitizalizationPostProcessorException(
get_class($indexQueueInitializationPostProcessor) . ' must implement interface ' . InitializationPostProcessor::class,
1345815561
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

use ApacheSolrForTypo3\Solr\Domain\Site\Site;
use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\System\Cache\TwoLevelCache;
use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration;
use ApacheSolrForTypo3\Solr\System\Page\Rootline;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use InvalidArgumentException;
use RuntimeException;
use Throwable;
use TYPO3\CMS\Backend\Utility\BackendUtility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\RootPageResolver;
use ApacheSolrForTypo3\Solr\Domain\Site\SiteInterface;
use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\FrontendEnvironment;
use ApacheSolrForTypo3\Solr\IndexQueue\Queue;
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
Expand All @@ -31,7 +32,6 @@
use ApacheSolrForTypo3\Solr\Util;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Doctrine\DBAL\Exception as DBALException;
use InvalidArgumentException;
use Throwable;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\UpdateHandler\EventListener\Events\ProcessingFinishedEventInterface;
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\UpdateHandler\Events\DataUpdateEventInterface;
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\UpdateHandler\GarbageHandler;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration;
use InvalidArgumentException;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\LastSearches;

use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\System\Records\AbstractRepository;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Doctrine\DBAL\Exception as DBALException;
use InvalidArgumentException;
use function json_encode;

class LastSearchesRepository extends AbstractRepository
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Search/Query/ParameterBuilder/Operator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder;

use InvalidArgumentException;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;

/**
* The Operator ParameterProvider is responsible to build the solr query parameters
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Search/ResultSet/Facets/FacetRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased\QueryGroup\QueryGroupPackage;
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\DateRange\DateRangePackage;
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\NumericRange\NumericRangePackage;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\System\Object\AbstractClassRegistry;
use InvalidArgumentException;

/**
* Class FacetRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets;

class InvalidFacetPackageException extends \Exception
use ApacheSolrForTypo3\Solr\Exception;

class InvalidFacetPackageException extends Exception
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets;

class InvalidFacetParserException extends \Exception
use ApacheSolrForTypo3\Solr\Exception;

class InvalidFacetParserException extends Exception
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets;

class InvalidQueryBuilderException extends \Exception
use ApacheSolrForTypo3\Solr\Exception;

class InvalidQueryBuilderException extends Exception
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets;

use Exception;
use ApacheSolrForTypo3\Solr\Exception;

class InvalidUrlDecoderException extends Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\NumericRange;

use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\FacetUrlDecoderInterface;
use InvalidArgumentException;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;

/**
* Parser to build Solr range queries from tx_solr[filter]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets;

use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -83,12 +84,13 @@ protected function getRequirementMet(AbstractFacet $facet, $requirement = [])
*
* @param string $facetNameToCheckRequirementsOn
* @return AbstractFacetItem[]
* @throws InvalidArgumentException
*/
protected function getSelectedItemValues(AbstractFacet $facet, $facetNameToCheckRequirementsOn)
{
$facetToCheckRequirements = $facet->getResultSet()->getFacets()->getByName($facetNameToCheckRequirementsOn)->getByPosition(0);
if (!$facetToCheckRequirements instanceof AbstractFacet) {
throw new \InvalidArgumentException('Requirement for unexisting facet configured');
throw new InvalidArgumentException('Requirement for unexisting facet configured');
}

if (!$facetToCheckRequirements->getIsUsed()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\Parser;

use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
use InvalidArgumentException;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result;

use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\System\Solr\Document\Document;
use InvalidArgumentException;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Search/ResultSet/Sorting/Sorting.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting;

use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
use InvalidArgumentException;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;

/**
* Class Sorting
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting;

use InvalidArgumentException;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace ApacheSolrForTypo3\Solr\Domain\Site\Exception;

use Exception;
use ApacheSolrForTypo3\Solr\Exception;

class InvalidSiteConfigurationCombinationException extends Exception
{
Expand Down
24 changes: 24 additions & 0 deletions Classes/Domain/Site/Exception/InvalidSiteRootPageException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace ApacheSolrForTypo3\Solr\Domain\Site\Exception;

use ApacheSolrForTypo3\Solr\Exception;

class InvalidSiteRootPageException extends Exception
{
}
2 changes: 1 addition & 1 deletion Classes/Domain/Site/SiteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
namespace ApacheSolrForTypo3\Solr\Domain\Site;

use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\RootPageResolver;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\FrontendEnvironment;
use ApacheSolrForTypo3\Solr\System\Cache\TwoLevelCache;
use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration;
use ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository;
use ApacheSolrForTypo3\Solr\System\Util\SiteUtility;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use InvalidArgumentException;
use Throwable;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Registry;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Variants/IdBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace ApacheSolrForTypo3\Solr\Domain\Variants;

use InvalidArgumentException;
use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace ApacheSolrForTypo3\Solr\Exception\Index\Queue;

use ApacheSolrForTypo3\Solr\Exception;

/**
* Exception that is thrown if an index queue post processor is invalid.
*/
class InvalidIndexQueueInitizalizationPostProcessorException extends Exception
{
}
27 changes: 27 additions & 0 deletions Classes/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace ApacheSolrForTypo3\Solr\Exception;

use ApacheSolrForTypo3\Solr\Exception;

/**
* Exception that is thrown if a given argument is invalid.
*/
class InvalidArgumentException extends Exception
{
}
Loading

0 comments on commit db3f169

Please sign in to comment.