@param Throwable $throwable
@param string    $text
@param int       $status

@return ThrowableResponseInterface
355695
private function createThrowableTextResponse(
        Throwable $throwable,
        string $text,
        int $status
    ): ThrowableResponseInterface {
        return new class ($throwable, $text, $status) extends TextResponse implements ThrowableResponseInterface
        {
            use ThrowableResponseTrait;

            /**
             * @param Throwable $throwable
             * @param string    $text
             * @param int       $status
             */
            public function __construct(Throwable $throwable, string $text, int $status)
            {
                parent::__construct($text, $status);
                $this->setThrowable($throwable);
            }
        };
    }
993941
public function throwableToResponse(\Throwable $e) : ResponseInterface
    {
        $response = $this->responseFactory->createResponse();
        
        if ($e instanceof HttpException) {
            $statusCode = $e->getStatusCode();
        } else {
            $statusCode = $e->getCode() != 0 ? $e->getCode() : 500;
        }
        
        $response = $response->withStatus($statusCode);
        
        try {
            $html = $this->getHtmlFromTemplate($e);
        } catch (\Throwable $e) {
            $html = $this->getHtmlForException($e);
        }
        
        $response->getBody()->write($html);
        
        return $response;
    }
1299729
public function setStatusCode($statusCode, $text = null)
    {
        // Fallback status code message if missing
        if (! empty($text)) {
            $statusText = $text;
        } elseif (! empty(self::$statusTexts[$statusCode])) {
            $statusText = self::$statusTexts[$statusCode];
        } else {
            $statusText = 'Undefined code';
        }

        // Set status code and text
        $this->statusCode = $statusCode;
        $this->statusText = $statusText;

        // Validate status code
        if ($this->isInvalid()) {
            throw new InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $statusCode));
        }

        return $this;
    }
408876
protected function createDefaultThrowableResponse(Throwable $throwable): ThrowableResponseInterface
    {
        $status   = static::DEFAULT_HTTP_ERROR_CODE;
        $response = new class ($throwable, $status) extends TextResponse implements ThrowableResponseInterface
        {
            use ThrowableResponseTrait;

            /**
             * @param Throwable $throwable
             * @param int       $status
             */
            public function __construct(Throwable $throwable, int $status)
            {
                parent::__construct((string)$throwable, $status);
                $this->setThrowable($throwable);
            }
        };

        return $response;
    }
567048
public static function createIncorrectStatus($status, \Exception $e = null)
    {
        $message = 'Expected server status to be "OK", got "%s" instead';

        return new static(sprintf($message, $status), null, $e);
    }
603988
private function renderThrowableStack(Throwable $throwable, int $number = 0): void
    {
        $this->io->writeln(sprintf(' #%d:', $number));
        $throwableClass = get_class($throwable);
        $this->io->writeln(sprintf('  - <comment>exception:</comment> %s', $throwableClass));
        $this->io->writeln(sprintf('  - <comment>file:</comment> <info>%s</info>', $throwable->getFile()));
        $this->io->writeln(sprintf('  - <comment>line:</comment> %d', $throwable->getLine()));
        $this->io->writeln(sprintf('  - <comment>message:</comment> %s', $throwable->getMessage()));

        $previous = $throwable->getPrevious();

        if ($previous !== null) {
            $this->renderThrowableStack($previous, $number + 1);
        }
    }
861701
public static void status(String statusText) {
        try {
            getEventManager().fireLocalEvent(STATUS_EVENT, statusText == null ? "" : statusText);
        } catch (Throwable e) {
            log.error(e);
        }
    }
1323557
public static Status fromThrowable(Throwable t) {
    Throwable cause = checkNotNull(t, "t");
    while (cause != null) {
      if (cause instanceof StatusException) {
        return ((StatusException) cause).getStatus();
      } else if (cause instanceof StatusRuntimeException) {
        return ((StatusRuntimeException) cause).getStatus();
      }
      cause = cause.getCause();
    }
    // Couldn't find a cause with a Status
    return UNKNOWN.withCause(t);
  }
1020891
public function asResponse($input, $status = self::OK, array $header = [])
    {
        return ResponseHelper::fill($this->response, $input, $status, $header);
    }
802759
public function respondExceptionError($status, $message, $status_code, $payload)
    {
        $responseData = $this->getResponseStructure($status, $payload, $message);
        $response = new JsonResponse($responseData, $status_code, $this->getHeaders());

        return $response;
    }
764606
public function setPHPThrowable($throwable)
    {
        if (!$throwable instanceof Throwable && !$throwable instanceof Exception) {
            throw new InvalidArgumentException('The throwable must implement Throwable or extend Exception.');
        }

        $this->setName(get_class($throwable))
             ->setMessage($throwable->getMessage())
             ->setStacktrace(Stacktrace::fromBacktrace($this->config, $throwable->getTrace(), $throwable->getFile(), $throwable->getLine()));

        if (method_exists($throwable, 'getPrevious')) {
            $this->setPrevious($throwable->getPrevious());
        }

        return $this;
    }
198310
private function dispatchException(\Throwable $t) {
		array_unshift($this->dispatchingThrowables, $t);
		$numDispatchingThrowables = sizeof($this->dispatchingThrowables);
		
		if (!N2N::isInitialized() || 2 < $numDispatchingThrowables || (2 == $numDispatchingThrowables 
				&& !($this->dispatchingThrowables[1] instanceof StatusException)) || !$this->stable) {
			if (!isset($_SERVER['HTTP_HOST'])) {
				$this->renderExceptionConsoleInfo($t);
				return;
			}
			
			$this->renderFatalExceptionsHtmlInfo($this->dispatchingThrowables);
			return;
		}
		
		if (!N2N::isHttpContextAvailable()) {
			$this->renderExceptionConsoleInfo($t);
			return;
		}

		try {
			$this->renderBeautifulExceptionView($t);
		} catch (\Throwable $t) {
			$this->handleThrowable($t);
		}
	}
200173
protected function textHandler(ParsingState $state, $text)
    {
        /** @var $node TextNode */
        $node = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\TextNode::class, $text);
        $this->callInterceptor($node, InterceptorInterface::INTERCEPT_TEXT, $state);

        $state->getNodeFromStack()->addChildNode($node);
    }
198299
public static function colorize($text, $status)
    {
        $out = "";
        switch ($status) {
            case "SUCCESS":
                $out = "[42m"; //Green background
                break;
            case "FAILURE":
                $out = "[41m"; //Red background
                break;
            case "WARNING":
                $out = "[43m"; //Yellow background
                break;
            case "NOTE":
                $out = "[44m"; //Blue background
                break;
            default:
                throw new Exception("Invalid status: " . $status);
        }
        return chr(27) . "$out" . "$text" . chr(27) . "[0m" . PHP_EOL;
    }
1165406
protected function renderStatically(int $statusCode, \Throwable $exception)
    {
        $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
        $exceptionHeader = '<div class="Flow-Debug-Exception-Header">';
        while (true) {
            $filepaths = Debugger::findProxyAndShortFilePath($exception->getFile());
            $filePathAndName = $filepaths['proxy'] !== '' ? $filepaths['proxy'] : $filepaths['short'];
            $exceptionMessageParts = $this->splitExceptionMessage($exception->getMessage());

            $exceptionHeader .= '<h1 class="ExceptionSubject">' . htmlspecialchars($exceptionMessageParts['subject']) . '</h1>';
            if ($exceptionMessageParts['body'] !== '') {
                $exceptionHeader .= '<p class="ExceptionBody">' . nl2br(htmlspecialchars($exceptionMessageParts['body'])) . '</p>';
            }

            $exceptionHeader .= '<table class="Flow-Debug-Exception-Meta"><tbody>';
            $exceptionHeader .= '<tr><th>Exception Code</th><td class="ExceptionProperty">' . $exception->getCode() . '</td></tr>';
            $exceptionHeader .= '<tr><th>Exception Type</th><td class="ExceptionProperty">' . get_class($exception) . '</td></tr>';
            if ($exception instanceof WithReferenceCodeInterface) {
                $exceptionHeader .= '<tr><th>Log Reference</th><td class="ExceptionProperty">' . $exception->getReferenceCode() . '</td></tr>';
            }

            $exceptionHeader .= '<tr><th>Thrown in File</th><td class="ExceptionProperty">' . $filePathAndName . '</td></tr>';
            $exceptionHeader .= '<tr><th>Line</th><td class="ExceptionProperty">' . $exception->getLine() . '</td></tr>';

            if ($filepaths['proxy'] !== '') {
                $exceptionHeader .= '<tr><th>Original File</th><td class="ExceptionProperty">' . $filepaths['short'] . '</td></tr>';
            }
            $exceptionHeader .= '</tbody></table>';

            if ($exception->getPrevious() === null) {
                break;
            }
            $exceptionHeader .= '<br /><h2>Nested Exception</h2>';
            $exception = $exception->getPrevious();
        }

        $exceptionHeader .= '</div>';

        $backtraceCode = Debugger::getBacktraceCode($exception->getTrace());

        $footer = '<div class="Flow-Debug-Exception-Footer">';
        $footer .= '<table class="Flow-Debug-Exception-InstanceData"><tbody>';
        if (defined('FLOW_PATH_ROOT')) {
            $footer .= '<tr><th>Instance root</th><td class="ExceptionProperty">' . FLOW_PATH_ROOT . '</td></tr>';
        }
        if (Bootstrap::$staticObjectManager instanceof ObjectManagerInterface) {
            $bootstrap = Bootstrap::$staticObjectManager->get(Bootstrap::class);
            $footer .= '<tr><th>Application Context</th><td class="ExceptionProperty">' . $bootstrap->getContext() . '</td></tr>';
            $footer .= '<tr><th>Request Handler</th><td class="ExceptionProperty">' . get_class($bootstrap->getActiveRequestHandler()) . '</td></tr>';
        }
        $footer .= '</tbody></table>';
        $footer .= '</div>';

        echo sprintf($this->htmlExceptionTemplate,
            $statusCode . ' ' . $statusMessage,
            file_get_contents(__DIR__ . '/../../Resources/Public/Error/Exception.css'),
            $exceptionHeader,
            $backtraceCode,
            $footer
        );
    }
958832
private function throwableToResponse(\Throwable $throwable, ResponseInterface $response): void
    {
        $response->setStatusCode(new StatusCode(StatusCode::INTERNAL_SERVER_ERROR));
        $response->setHeaders(new HeaderCollection());
        $response->setContent($this->throwableToHtml($throwable));
    }
1262952
public function prepareResponse($content, $status = null)
    {
        $response = new Response;

        $response->setContent($content);

        if (isset($status)) {
            $response->setStatusCode($status);
        }

        return $response->send();
    }