コード例 #1
0
 public function testExtractExceptionInfoWithPrevious()
 {
     $previous = new Exception('previousMessage');
     $exception = new Exception('testMessage', null, $previous);
     $info = FajrUtils::extractExceptionInfo($exception);
     $this->assertTrue(is_array($info['previous']));
     $infoPrevious = $info['previous'];
     $this->assertEquals($infoPrevious['message'], 'previousMessage');
     $this->assertEquals($infoPrevious['file'], $previous->getFile());
     $this->assertEquals($infoPrevious['line'], $previous->getLine());
     $this->assertEquals($infoPrevious['code'], $previous->getCode());
     $this->assertEquals($infoPrevious['previous'], false);
     $trace = $exception->getTrace();
     $infoTrace = $infoPrevious['trace'];
     $this->assertEquals(count($infoTrace), count($trace));
     foreach ($infoTrace as $item) {
         foreach ($item as $key => $value) {
             if ($key == 'args') {
                 $this->assertTrue(is_array($value));
                 foreach ($value as $arg) {
                     $this->assertTrue(is_string($arg));
                 }
             } else {
                 if ($key == 'line') {
                     $this->assertTrue(is_string($value) || is_int($value));
                 } else {
                     $this->assertTrue(is_string($value));
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: Fajr.php プロジェクト: BGCX067/fajr-svn-to-git
 /**
  * Set an exception to be displayed.
  * @param Exception $ex
  */
 private function setException(Exception $ex)
 {
     if ($this->context == null) {
         // May happen if exception occured before or in context
         // instantiation. We don't know how to handle the
         // exception in this case, so just pass it to the
         // outer exception handler
         throw $ex;
     }
     $response = $this->context->getResponse();
     // Note: We can't store function agruments from
     // stacktrace for template rendering, because
     // it can hold cyclic dependency to Context
     // and thus makes order of destruction unpredictable.
     $info = FajrUtils::extractExceptionInfo($ex);
     $response->set('exception', $info);
     $response->set('showStackTrace', FajrConfig::get('Debug.Exception.ShowStacktrace'));
     $response->setTemplate('exception');
 }
コード例 #3
0
ファイル: Fajr.php プロジェクト: BGCX067/fajr-git
 /**
  * Set an exception to be displayed.
  * @param Exception $ex
  */
 private function renderExceptionResponse(Exception $ex)
 {
     // Note: We can't store function arguments from
     // stacktrace for template rendering, because
     // it can hold cyclic dependency to Context
     // and thus makes order of destruction unpredictable.
     error_log($ex);
     $info = FajrUtils::extractExceptionInfo($ex);
     $params = array('exception' => $info, 'showStackTrace' => $this->config->get('Debug.Exception.ShowStacktrace'));
     return $this->displayManager->renderResponse('exception', $params, null, 500);
 }