Exemplo n.º 1
0
 /**
  * @param Exception|Throwable $exception
  * @param SapiInterface       $sapi
  * @param ContainerInterface  $container
  *
  * @SuppressWarnings(PHPMD.ElseExpression)
  */
 private function handle($exception, SapiInterface $sapi, ContainerInterface $container)
 {
     $appConfig = $container->get(ConfigInterface::class)->getConfig(C::class);
     $message = 'Internal Server Error';
     $this->logException($exception, $container, $message);
     if ($appConfig[C::KEY_IS_LOG_ENABLED] === true) {
         $run = new Run();
         $handler = new PrettyPageHandler();
         // You can add app specific detailed data here
         $appSpecificDetails = [];
         $appName = $appConfig[C::KEY_NAME];
         if (empty($appSpecificDetails) === false) {
             $handler->addDataTable("{$appName} Details", $appSpecificDetails);
         }
         $handler->setPageTitle("Whoops! There was a problem with '{$appName}'.");
         $run->pushHandler($handler);
         $htmlMessage = $run->handleException($exception);
         $response = new HtmlResponse($htmlMessage, 500);
     } else {
         $response = new TextResponse($message, 500);
     }
     $sapi->handleResponse($response);
 }
Exemplo n.º 2
0
 /**
  * @param SapiInterface $sapi
  *
  * @return ServerRequestInterface
  */
 public static function defaultRequestFactory(SapiInterface $sapi)
 {
     return new ServerRequest($sapi->getServer(), $sapi->getFiles(), $sapi->getUri(), $sapi->getMethod(), $sapi->getRequestBody(), $sapi->getHeaders(), $sapi->getCookies(), $sapi->getQueryParams(), $sapi->getParsedBody());
 }