public function testGetCallStack()
 {
     try {
         $this->instanceFunction();
         $this->fail();
     } catch (Exception $e) {
         $formatter = new ExceptionFormatter($e);
     }
     $calls = $formatter->getCallStack();
     $this->assertTrue(StringUtil::startsWith($calls[0], 'function genericFuncion()'));
     $this->assertTrue(StringUtil::startsWith($calls[1], 'ExceptionFormatterTest::{closure}()'));
     $this->assertTrue(StringUtil::startsWith($calls[2], 'ExceptionFormatterTest::staticFunction()'));
     $this->assertTrue(StringUtil::startsWith($calls[3], 'ExceptionFormatterTest->instanceFunction()'));
 }
Esempio n. 2
0
 /**
  * Display a generic error page, and information about the error
  */
 private function handleError($exception)
 {
     $formatter = new ExceptionFormatter($exception);
     $content = sprintf('
         <!DOCTYPE html>
         <html>
           <head>
             <meta charset="utf-8">
             <title>%s</title>
           </head>
           <body>
             <h1>%s</h1>
             <p>%s</p>
             %s
           </body>
         </html>', $exception->getMessage(), 'There\'s been an error', 'The page could not be displayed', $formatter->format());
     $response = new Response($content, 503);
     $response->send();
 }