/** * @inherit */ public function handleError(\R3H6\Error404page\Domain\Model\Error $error) { if ($this->httpService->isOwnRequest()) { $this->getLogger()->debug("Throw exception 1475311053"); throw new \Exception("Error processing request", 1475311053); } if ($this->extensionConfiguration->is('enableErrorLog')) { $this->errorRepository->log($error); } $cacheIdentifier = $this->errorHandlerCache->calculateCacheIdentifier($error); $errorHandler = $this->errorHandlerCache->get($cacheIdentifier); if ($errorHandler === null) { foreach ($this->getErrorHandlers() as $errorHandler) { try { $this->getLogger()->debug('Try handle error with ' . get_class($errorHandler)); if ($errorHandler->handleError($error)) { $this->errorHandlerCache->set($cacheIdentifier, $errorHandler); break; } } catch (\Exception $exception) { $this->getLogger()->debug('Could not handle error in ' . get_class($errorHandler) . ': ' . $exception->getMessage()); } } } $this->getLogger()->debug('Get error handler output of ' . get_class($errorHandler)); return $errorHandler->getOutput($error); }
/** * @test */ public function calculateCacheIdentifierRespectsCurrentUrlForForbiddenErrors() { /** @var \R3H6\Error404page\Domain\Model\Error $errorFixture */ $errorFixture = new Error(); $errorFixture->setStatusCode(Error::STATUS_CODE_FORBIDDEN); $cacheIdentifier1 = $this->subject->calculateCacheIdentifier($errorFixture); $errorFixture->setCurrentUrl('page/not/found.html'); $cacheIdentifier2 = $this->subject->calculateCacheIdentifier($errorFixture); $this->assertNotEquals($cacheIdentifier1, $cacheIdentifier2); }