Skip to content

Commit

Permalink
Merge pull request #2896 from kdambekalns/task/error-logging-buildsub…
Browse files Browse the repository at this point in the history
…backend

TASK: Add logging to TaggableMultiBackend.buildSubBackend
  • Loading branch information
kdambekalns committed Dec 14, 2022
2 parents 4f5a212 + 3bc31fe commit e133d10
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Neos.Cache/Classes/Backend/TaggableMultiBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* source code.
*/

use Neos\Cache\Exception;
use Neos\Flow\Log\Utility\LogEnvironment;
use Throwable;

Expand All @@ -27,6 +28,10 @@ class TaggableMultiBackend extends MultiBackend implements TaggableBackendInterf
protected function buildSubBackend(string $backendClassName, array $backendOptions): ?BackendInterface
{
if (!is_subclass_of($backendClassName, TaggableBackendInterface::class)) {
$message = sprintf('Failed building sub backend %s for %s because it does not implement %s', $backendClassName, get_class($this), TaggableBackendInterface::class);
$throwable = new Exception($message);
$this->logger?->error(($this->throwableStorage ? $this->throwableStorage->logThrowable($throwable) : $message), LogEnvironment::fromMethodName(__METHOD__));
$this->handleError($throwable);
return null;
}
return parent::buildSubBackend($backendClassName, $backendOptions);
Expand Down

0 comments on commit e133d10

Please sign in to comment.