当前位置: 首页>>代码示例>>PHP>>正文


PHP Exception::getPrevious方法代码示例

本文整理汇总了PHP中Exception::getPrevious方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getPrevious方法的具体用法?PHP Exception::getPrevious怎么用?PHP Exception::getPrevious使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exception的用法示例。


在下文中一共展示了Exception::getPrevious方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: displayError

 /**
  * handle errors
  *
  * @param \Exception                                       $error  the error stack
  * @param Symfony\Component\Console\Output\OutputInterface $output the ooutput interface
  * @param string                                           $prefix the prefix to indent the text
  */
 protected function displayError(\Exception $error, OutputInterface $output, $prefix = '')
 {
     $output->writeln('<error>' . $prefix . $error->getMessage() . '</error>');
     if ($error->getPrevious()) {
         $this->displayError($error->getPrevious(), $output, "\t - ");
     }
 }
开发者ID:pfefferle,项目名称:webfinger-cli,代码行数:14,代码来源:WebFingerCommand.php

示例2: getFilteredStackTrace

 public static function getFilteredStackTrace(Exception $e, $asString = true)
 {
     $stackTrace = $asString ? '' : array();
     $trace = $e->getPrevious() ? $e->getPrevious()->getTrace() : $e->getTrace();
     if ($e instanceof \PHPUnit_Framework_ExceptionWrapper) {
         $trace = $e->getSerializableTrace();
     }
     foreach ($trace as $step) {
         if (self::classIsFiltered($step)) {
             continue;
         }
         if (self::fileIsFiltered($step)) {
             continue;
         }
         if (!$asString) {
             $stackTrace[] = $step;
             continue;
         }
         if (!isset($step['file'])) {
             continue;
         }
         $stackTrace .= $step['file'] . ':' . $step['line'] . "\n";
     }
     return $stackTrace;
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:25,代码来源:Filter.php

示例3: exceptionToArray

 public static function exceptionToArray(\Exception $e)
 {
     $a = array('code' => $e->getCode(), 'message' => $e->getMessage());
     if ($e->getPrevious() !== null) {
         $a['previous'] = self::exceptionToArray($e->getPrevious());
     }
     return $a;
 }
开发者ID:domotique-s3,项目名称:dbData,代码行数:8,代码来源:JsonHandler.php

示例4: _formatException

 /**
  * Format exception
  *
  * @param Exception $e Exception
  * @return array
  */
 private function _formatException(Exception $e)
 {
     $result = ['message' => $e->getMessage(), 'code' => $e->getCode(), 'trace' => $e->getTrace()];
     if ($previous = $e->getPrevious()) {
         $result['previous'] = $this->_formatException($e->getPrevious());
     }
     return $result;
 }
开发者ID:rockxcn,项目名称:messenger,代码行数:14,代码来源:Json.php

示例5: displayError

function displayError(Exception $error)
{
    echo $error->getMessage() . "\n";
    if ($error->getPrevious()) {
        echo ' Underlying error: ';
        displayError($error->getPrevious());
    }
}
开发者ID:mitgedanken,项目名称:Net_WebFinger,代码行数:8,代码来源:webfinger-cli.php

示例6: getPreviousExceptionInspector

 /**
  * Returns an Inspector for a previous Exception, if any.
  *
  * @return Inspector
  */
 public function getPreviousExceptionInspector()
 {
     if ($this->previousExceptionInspector === null) {
         $previousException = $this->exception->getPrevious();
         if ($previousException) {
             $this->previousExceptionInspector = new Inspector($previousException);
         }
     }
     return $this->previousExceptionInspector;
 }
开发者ID:bafs,项目名称:booboo,代码行数:15,代码来源:Inspector.php

示例7: findCodeDb

 public static function findCodeDb(Exception $e)
 {
     if (isset($e->errorInfo)) {
         return $e->errorInfo;
     }
     if ($e->getPrevious()) {
         return self::findCodeDb($e->getPrevious());
     } else {
         return false;
     }
 }
开发者ID:ao-lab,项目名称:ao-zend,代码行数:11,代码来源:Error.php

示例8: buildError

 /**
  * @param \Exception $exception
  *
  * @return array
  */
 protected function buildError(\Exception $exception)
 {
     $result = ['code' => $exception->getCode(), 'message' => $exception->getMessage(), 'previous' => null, 'data' => null];
     if ($exception->getPrevious() !== null) {
         $result['previous'] = $this->buildError($exception->getPrevious());
     }
     if ($exception instanceof ExceptionInterface) {
         $result['data'] = $exception->getMetaData();
     }
     return $result;
 }
开发者ID:pmarien,项目名称:rest-api-response,代码行数:16,代码来源:ApiErrorResponse.php

示例9: serializeException

 /**
  * @param \Exception $exception
  * @return string
  */
 private static function serializeException(\Exception $exception)
 {
     $appendix = '';
     $info = array_merge($exception->getMessage() ? array(self::serialize($exception->getMessage())) : array(), $exception->getCode() ? array(self::serialize($exception->getCode())) : array());
     if ($info) {
         $appendix = '(' . implode(', ', $info) . ')';
     }
     if ($exception->getPrevious()) {
         $appendix .= ' <- ' . self::serializeException($exception->getPrevious());
     }
     return self::serializeObject($exception, $appendix);
 }
开发者ID:watoki,项目名称:reflect,代码行数:16,代码来源:ValuePrinter.php

示例10: __construct

 /**
  * Create Serializable exception from real exception
  * @param \Exception $exception
  */
 public function __construct(\Exception $exception)
 {
     $this->message = $exception->getMessage();
     $this->traceString = $exception->getTraceAsString();
     $this->code = $exception->getCode();
     $this->file = $exception->getFile();
     $this->line = $exception->getLine();
     if ($exception->getPrevious() instanceof \Exception) {
         $this->previous = new SerializableException($exception->getPrevious());
     }
     $this->trace = $exception->getTrace();
     $this->cleanupTrace();
 }
开发者ID:RogerWaters,项目名称:react-thread-pool,代码行数:17,代码来源:SerializableException.php

示例11: handle

 /**
  * {@inheritdoc}
  */
 public function handle(\Exception $exception)
 {
     if (null !== ($preEx = $exception->getPrevious())) {
         throw $preEx;
     }
     throw $exception;
 }
开发者ID:syrma-php,项目名称:web-container,代码行数:10,代码来源:ExceptionHandlerStub.php

示例12: displayExceptionObject

function displayExceptionObject(Exception $e)
{
    echo "\$e = >{$e}<\n";
    // calls __toString
    echo "getMessage:       >" . $e->getMessage() . "<\n";
    echo "getCode:          >" . $e->getCode() . "<\n";
    echo "getPrevious:      >" . $e->getPrevious() . "<\n";
    echo "getFile:          >" . $e->getFile() . "<\n";
    echo "getLine:          >" . $e->getLine() . "<\n";
    echo "getTraceAsString: >" . $e->getTraceAsString() . "<\n";
    $traceInfo = $e->getTrace();
    var_dump($traceInfo);
    echo "Trace Info:" . (count($traceInfo) == 0 ? " none\n" : "\n");
    foreach ($traceInfo as $traceInfoKey => $traceLevel) {
        echo "Key[{$traceInfoKey}]:\n";
        foreach ($traceLevel as $levelKey => $levelVal) {
            if ($levelKey != "args") {
                echo "  Key[{$levelKey}] => >{$levelVal}<\n";
            } else {
                echo "  Key[{$levelKey}]:\n";
                foreach ($levelVal as $argKey => $argVal) {
                    echo "    Key[{$argKey}] => >{$argVal}<\n";
                }
            }
        }
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:27,代码来源:set_exception_handler.php

示例13: handleException

 /**
  * Handles a thrown exception.  Will also log extra information if the exception happens to by a MySql deadlock.
  *
  * @param \Exception $exception The exception captured.
  *
  * @return null
  */
 protected function handleException($exception)
 {
     // Log MySQL deadlocks
     if ($exception instanceof \CDbException && strpos($exception->getMessage(), 'Deadlock') !== false) {
         $data = craft()->db->createCommand('SHOW ENGINE INNODB STATUS')->query();
         $info = $data->read();
         $info = serialize($info);
         Craft::log('Deadlock error, innodb status: ' . $info, LogLevel::Error, 'system.db.CDbCommand');
     }
     // If this is a Twig Runtime exception, use the previous one instead
     if ($exception instanceof \Twig_Error_Runtime) {
         if ($previousException = $exception->getPrevious()) {
             $exception = $previousException;
         }
     }
     // Special handling for Twig syntax errors
     if ($exception instanceof \Twig_Error) {
         $this->handleTwigError($exception);
     } else {
         if ($exception instanceof DbConnectException) {
             $this->handleDbConnectionError($exception);
         } else {
             parent::handleException($exception);
         }
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:33,代码来源:ErrorHandler.php

示例14: display

 /**
  * Outputs the error popup, or a plain message, depending on the response content type.
  *
  * @param \Exception|\Error      $exception Note: can't be type hinted, for PHP7 compat.
  * @param ResponseInterface|null $response  If null, it outputs directly to the client. Otherwise, it assumes the
  *                                          object is a new blank response.
  * @return ResponseInterface|null
  */
 static function display($exception, ResponseInterface $response = null)
 {
     // For HTML pages, output the error popup
     if (strpos(get($_SERVER, 'HTTP_ACCEPT'), 'text/html') !== false) {
         ob_start();
         ErrorConsoleRenderer::renderStyles();
         $stackTrace = self::getStackTrace($exception->getPrevious() ?: $exception);
         ErrorConsoleRenderer::renderPopup($exception, self::$appName, $stackTrace);
         $popup = ob_get_clean();
         // PSR-7 output
         if ($response) {
             $response->getBody()->write($popup);
             return $response->withStatus(500);
         }
         // Direct output
         echo $popup;
     } else {
         // PSR-7 output
         if ($response) {
             $response->getBody()->write($exception->getMessage());
             if (self::$devEnv) {
                 $response->getBody()->write("\n\nStack trace:\n" . $exception->getTraceAsString());
             }
             return $response->withoutHeader('Content-Type')->withHeader('Content-Type', 'text-plain')->withStatus(500);
         }
         // Direct output
         header("Content-Type: text/plain");
         http_response_code(500);
         echo $exception->getMessage();
         if (self::$devEnv) {
             echo "\n\nStack trace:\n" . $exception->getTraceAsString();
         }
     }
     return null;
 }
开发者ID:impactwave,项目名称:php-web-console,代码行数:43,代码来源:ErrorConsole.php

示例15: handle

 public static function handle(\Exception $ex)
 {
     if ($ex->getPrevious() instanceof ConsoleException) {
         Console::error($ex->getMessage());
         return;
     }
     $handles = Settings::load('exception');
     if (isset($handles) && !empty($handles)) {
         foreach ($handles as $key => $value) {
             if (self::recursive($ex, $key)) {
                 if (is_callable($value)) {
                     call_user_func($value, $ex);
                     return;
                 } else {
                     /** @var ExceptionHandle $handle */
                     $handle = DI::get($value);
                     if (isset($handle)) {
                         $handle->handle();
                         return;
                     }
                 }
             }
         }
     }
     throw $ex;
 }
开发者ID:sanzhumu,项目名称:xaircraft1.1,代码行数:26,代码来源:ExceptionManager.php


注:本文中的Exception::getPrevious方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。