Ejemplo n.º 1
0
 /**
  * @param ApplicationInterface $app
  */
 public function __invoke(ApplicationInterface $app)
 {
     $exception = $app->getException();
     if (php_sapi_name() == 'cli') {
         throw $exception;
     } else {
         $output = Tag::h1('An error occurred');
         do {
             $output .= $this->renderException($exception);
         } while ($exception = $exception->getPrevious());
         $output .= Tag::h2('Workflow');
         foreach ($app->getExecutionTrace() as $step => $middlewares) {
             $output .= Tag::h3('Step: ' . $step);
             /**
              * @var Hook $hook
              */
             foreach ($middlewares as $middleware) {
                 $output .= Tag::dt([$middleware->getReference() . ': ', $middleware->getDescription()]);
             }
         }
         // display config
         $output .= Tag::h2('Configuration');
         ob_start();
         var_dump($app->getConfig()->getInternalValue());
         $output .= ob_get_clean();
         // display services
         $output .= Tag::h2('Services');
         foreach ($app->getServicesFactory()->getServices() as $spec) {
             $output .= Tag::h3($spec->getId());
             ob_start();
             var_dump($spec);
             $output .= ob_get_clean();
         }
         // manually emit response
         (new SapiEmitter())->emit((new HtmlResponse($output))->withStatus(500));
     }
 }