public function recognizeErrorResponseHandler($exception, $inspector, Run $run)
    {
        $app = $this->application;

        $handlerClass = PrettyPageHandler::class;
        if ($app->isCli() || false === $app->getConfig(ApplicationInterface::KEY_ERROR, ApplicationInterface::DEFAULT_ERROR)) {
            $handlerClass = PlainTextHandler::class;
        }

        if ($app instanceof Application) {
            if ($app->isSoapRequest() || $app->isXmlRequest()) {
                $handlerClass = XmlResponseHandler::class;
            } elseif ($app->isAjaxRequest() || $app->isJsonRequest()) {
                $handlerClass = JsonResponseHandler::class;
            }
        }

        /** @var HandlerInterface $handler */
        $handler = new $handlerClass;
        $handler->setException($exception);
        $handler->setInspector($inspector);
        $handler->setRun($run);
        return $handler->handle();
    }
public function recognizeErrorResponseHandler($exception, $inspector, Run $run)
    {
        $app = $this->application;

        $handlerClass = PrettyPageHandler::class;
        if ($app->isCli() || false === $app->getConfig(ApplicationInterface::KEY_ERROR, ApplicationInterface::DEFAULT_ERROR)) {
            $handlerClass = PlainTextHandler::class;
        }

        if ($app instanceof Application) {
            if ($app->isSoapRequest() || $app->isXmlRequest()) {
                $handlerClass = XmlResponseHandler::class;
            } elseif ($app->isAjaxRequest() || $app->isJsonRequest()) {
                $handlerClass = JsonResponseHandler::class;
            }
        }

        /** @var HandlerInterface $handler */
        $handler = new $handlerClass;
        $handler->setException($exception);
        $handler->setInspector($inspector);
        $handler->setRun($run);
        return $handler->handle();
    }
public function recognizeErrorResponseHandler ( $ exception , $ inspector , Run $ run ) { $ app = $ this -> application ; $ handlerClass = PrettyPageHandler :: class ; if ( $ app -> isCli ( ) || false === $ app -> getConfig ( ApplicationInterface :: KEY_ERROR , ApplicationInterface :: DEFAULT_ERROR ) ) { $ handlerClass = PlainTextHandler :: class ; } if ( $ app instanceof Application ) { if ( $ app -> isSoapRequest ( ) || $ app -> isXmlRequest ( ) ) { $ handlerClass = XmlResponseHandler :: class ; } elseif ( $ app -> isAjaxRequest ( ) || $ app -> isJsonRequest ( ) ) { $ handlerClass = JsonResponseHandler :: class ; } } /** @var HandlerInterface $handler */ $ handler = new $ handlerClass ; $ handler -> setException ( $ exception ) ; $ handler -> setInspector ( $ inspector ) ; $ handler -> setRun ( $ run ) ; return $ handler -> handle ( ) ; }
Recognize response handler for error by content type and environment.

Cli is always handled as plaintext!

@param $exception
@param $inspector
@param Run $run
@return int|null
Recognize response handler for error by content type and environment .