/**
  * @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);
 }
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
// Override local page not found handling configuration
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = 'USER_FUNCTION:R3H6\\Error404page\\Domain\\Hook\\ErrorHandlerHook->pageNotFound';
if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['errorHandlers'])) {
    $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['errorHandlers'] = array();
}
// Cache configuration
if (!is_array($TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][\R3H6\Error404page\Domain\Cache\ErrorHandlerCache::IDENTIFIER])) {
    $TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][\R3H6\Error404page\Domain\Cache\ErrorHandlerCache::IDENTIFIER] = array();
}
// Debug log
if (\R3H6\Error404page\Configuration\ExtensionConfiguration::is('debug')) {
    $GLOBALS['TYPO3_CONF_VARS']['LOG']['R3H6']['Error404page']['writerConfiguration'] = array(\TYPO3\CMS\Core\Log\LogLevel::DEBUG => array('TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => array('logFile' => 'typo3temp/logs/debug.log')));
}