/**
  * Displays a human readable, partly beautified version of the given exception
  * and stops the application, return a non-zero exit code.
  *
  * @static
  * @param \Exception $exception
  * @return void
  */
 public static function writeResponseAndExit(\Exception $exception)
 {
     $response = new Response();
     $exceptionMessage = '';
     $exceptionReference = "\n<b>More Information</b>\n";
     $exceptionReference .= "  Exception code      #" . $exception->getCode() . "\n";
     $exceptionReference .= "  File                " . $exception->getFile() . ($exception->getLine() ? ' line ' . $exception->getLine() : '') . "\n";
     $exceptionReference .= $exception instanceof \TYPO3\Flow\Exception ? "  Exception reference #" . $exception->getReferenceCode() . "\n" : '';
     foreach (explode(chr(10), wordwrap($exception->getMessage(), 73)) as $messageLine) {
         $exceptionMessage .= "  {$messageLine}\n";
     }
     $response->setContent(sprintf("<b>Uncaught Exception</b>\n%s%s\n", $exceptionMessage, $exceptionReference));
     $response->send();
     exit(1);
 }
 /**
  * Starts the shutdown sequence
  *
  * @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants
  * @return void
  */
 protected function shutdown($runlevel)
 {
     $this->bootstrap->shutdown($runlevel);
     if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) {
         $this->objectManager->get(\TYPO3\Flow\Core\LockManager::class)->unlockSite();
     }
     exit($this->response->getExitCode());
 }
 /**
  * Starts the shutdown sequence
  *
  * @param string $runlevel Either "Compiletime" or "Runtime"
  * @return void
  */
 protected function shutdown($runlevel)
 {
     $this->bootstrap->shutdown($runlevel);
     if ($runlevel === 'Compiletime') {
         $this->objectManager->get('TYPO3\\Flow\\Core\\LockManager')->unlockSite();
     }
     exit($this->response->getExitCode());
 }
 /**
  * Sends the response and exits the CLI without any further code execution
  * Should be used for commands that flush code caches.
  *
  * @param integer $exitCode Exit code to return on exit
  * @return void
  */
 protected function sendAndExit($exitCode = 0)
 {
     $this->response->send();
     exit($exitCode);
 }
 /**
  * Formats and echoes the exception and its previous exceptions (if any) for the command line
  *
  * @param \Exception $exception The exception object
  * @return void
  */
 protected function echoExceptionCli(\Exception $exception)
 {
     $response = new CliResponse();
     $exceptionMessage = $this->renderSingleExceptionCli($exception);
     while (($exception = $exception->getPrevious()) !== NULL) {
         $exceptionMessage .= PHP_EOL . '<u>Nested exception:</u>' . PHP_EOL;
         $exceptionMessage .= $this->renderSingleExceptionCli($exception);
     }
     $response->setContent($exceptionMessage);
     $response->send();
     exit(1);
 }