Neos\Fusion\Core\Runtime::handleRenderingException PHP Method

handleRenderingException() public method

Handle an Exception thrown while rendering TypoScript according to settings specified in Neos.Fusion.rendering.exceptionHandler
public handleRenderingException ( array $typoScriptPath, Exception $exception, boolean $useInnerExceptionHandler = false ) : string
$typoScriptPath array
$exception Exception
$useInnerExceptionHandler boolean
return string
    public function handleRenderingException($typoScriptPath, \Exception $exception, $useInnerExceptionHandler = false)
    {
        $typoScriptConfiguration = $this->getConfigurationForPath($typoScriptPath);
        if (isset($typoScriptConfiguration['__meta']['exceptionHandler'])) {
            $exceptionHandlerClass = $typoScriptConfiguration['__meta']['exceptionHandler'];
            $invalidExceptionHandlerMessage = 'The class "%s" is not valid for property "@exceptionHandler".';
        } else {
            if ($useInnerExceptionHandler === true) {
                $exceptionHandlerClass = $this->settings['rendering']['innerExceptionHandler'];
            } else {
                $exceptionHandlerClass = $this->settings['rendering']['exceptionHandler'];
            }
            $invalidExceptionHandlerMessage = 'The class "%s" is not valid for setting "Neos.Fusion.rendering.exceptionHandler".';
        }
        $exceptionHandler = null;
        if ($this->objectManager->isRegistered($exceptionHandlerClass)) {
            $exceptionHandler = $this->objectManager->get($exceptionHandlerClass);
        }
        if ($exceptionHandler === null || !$exceptionHandler instanceof AbstractRenderingExceptionHandler) {
            $message = sprintf($invalidExceptionHandlerMessage . "\n" . 'Please specify a fully qualified classname to a subclass of %2$s\\AbstractRenderingExceptionHandler.' . "\n" . 'You might implement an own handler or use one of the following:' . "\n" . '%2$s\\AbsorbingHandler' . "\n" . '%2$s\\HtmlMessageHandler' . "\n" . '%2$s\\PlainTextHandler' . "\n" . '%2$s\\ThrowingHandler' . "\n" . '%2$s\\XmlCommentHandler', $exceptionHandlerClass, 'Neos\\Fusion\\Core\\ExceptionHandlers');
            throw new InvalidConfigurationException($message, 1368788926);
        }
        $exceptionHandler->setRuntime($this);
        if (array_key_exists('__objectType', $typoScriptConfiguration)) {
            $typoScriptPath .= sprintf('<%s>', $typoScriptConfiguration['__objectType']);
        }
        $output = $exceptionHandler->handleRenderingException($typoScriptPath, $exception);
        return $output;
    }

Usage Example

示例#1
0
 /**
  * Post-Processor which is called whenever this object is encountered in a Fluid
  * object access.
  *
  * Evaluates TypoScript objects and eel expressions.
  *
  * @return FusionPathProxy|mixed
  */
 public function objectAccess()
 {
     if (!$this->fusionRuntime->canRender($this->path)) {
         return $this;
     }
     try {
         return $this->fusionRuntime->evaluate($this->path, $this->templateImplementation);
     } catch (\Exception $exception) {
         return $this->fusionRuntime->handleRenderingException($this->path, $exception);
     }
 }