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


PHP Throwable::getPrevious方法代码示例

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


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

示例1: getPreviousExceptionInspector

 /**
  * Returns an Inspector for a previous Exception, if any.
  * @todo   Clean this up a bit, cache stuff a bit better.
  * @return Inspector
  */
 public function getPreviousExceptionInspector()
 {
     if ($this->previousExceptionInspector === null) {
         $previousException = $this->exception->getPrevious();
         if ($previousException) {
             $this->previousExceptionInspector = new Inspector($previousException);
         }
     }
     return $this->previousExceptionInspector;
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:15,代码来源:Inspector.php

示例2: dispatchException

 /**
  * Send exception message to client
  * @param \Exception $exception
  */
 public function dispatchException(\Throwable $exception)
 {
     if ($this->isActive()) {
         if ($this->dispatchPreviousExceptions && $exception->getPrevious()) {
             $this->dispatchException($exception->getPrevious());
         }
         $message = new \PhpConsole\ErrorMessage();
         $message->code = $exception->getCode();
         $message->class = get_class($exception);
         $message->data = $this->dumper->dump($exception->getMessage());
         $message->file = $exception->getFile();
         $message->line = $exception->getLine();
         $message->trace = self::fetchTrace($exception->getTrace(), $message->file, $message->line);
         $this->sendMessage($message);
     }
 }
开发者ID:beardedlinuxgeek,项目名称:php-console,代码行数:20,代码来源:Errors.php

示例3: handle_exception

 /**
  * @param \Exception|\Throwable $exception
  */
 public function handle_exception($exception)
 {
     if (getenv('APP_ENV') === 'dev') {
         list($code, $file, $line, $message, $previous, $trace, $trace_string) = [$exception->getCode(), $exception->getFile(), $exception->getLine(), $exception->getMessage(), $exception->getPrevious(), $exception->getTrace(), $exception->getTraceAsString()];
         $trace_info = "<b>file</b>: {$trace[0]['file']} <b>in line</b> ({$trace[0]['line']})";
         echo "<h2>COGS Runtime Exception: [::{$code}] {$message}</h2>";
         echo "<b>Trace:</b><br>";
         echo "<pre>{$trace_string}</pre>";
         echo "<b>Debug:</b><br>";
         dump(compact('code', 'file', 'line', 'message', 'previous', 'trace'));
     }
 }
开发者ID:anctemarry27,项目名称:cogs,代码行数:15,代码来源:ErrorHandlingServiceProvider.php

示例4: handle

 /**
  * @param Throwable $exception
  */
 public function handle(\Throwable $exception)
 {
     if ($exception instanceof HttpException) {
         http_response_code($exception->getStatusCode());
     }
     if (false === $this->debug) {
         return;
     }
     if (null !== $exception->getPrevious()) {
         $exception = $exception->getPrevious();
     }
     $message = $exception->getMessage();
     $trace = $exception->getTrace();
     array_unshift($trace, array('function' => '', 'file' => $exception->getFile() != null ? $exception->getFile() : null, 'line' => $exception->getLine() != null ? $exception->getLine() : null, 'args' => array()));
     $firstTrace = array_shift($trace);
     $firstTrace['excerpt'] = $this->excerpt($firstTrace['file'], $firstTrace['line']);
     array_unshift($trace, $firstTrace);
     echo $this->templateEngine->render(__DIR__ . '/templates/exception.php', array('message' => $message, 'trace' => $trace));
 }
开发者ID:PierreCharles,项目名称:uFramework-PHP,代码行数:22,代码来源:ExceptionHandler.php

示例5: resolveException

 /**
  * @deprecated
  * @internal
  * @param \Exception|\Throwable $e
  * @param string $query
  * @param array $params
  * @return DBALException
  */
 public function resolveException($e, $query = NULL, $params = [])
 {
     if ($this->throwOldKdybyExceptions !== TRUE) {
         return $e;
     }
     if ($e instanceof Doctrine\DBAL\DBALException && ($pe = $e->getPrevious()) instanceof \PDOException) {
         $info = $pe->errorInfo;
     } elseif ($e instanceof \PDOException) {
         $info = $e->errorInfo;
     } else {
         return new DBALException($e, $query, $params, $this);
     }
     if ($this->getDriver() instanceof Doctrine\DBAL\Driver\PDOMySql\Driver) {
         if ($info[0] == 23000 && $info[1] == self::MYSQL_ERR_UNIQUE) {
             // unique fail
             $columns = [];
             try {
                 if (preg_match('~Duplicate entry .*? for key \'([^\']+)\'~', $info[2], $m) && ($table = self::resolveExceptionTable($e)) && ($indexes = $this->getSchemaManager()->listTableIndexes($table)) && isset($indexes[$m[1]])) {
                     $columns[$m[1]] = $indexes[$m[1]]->getColumns();
                 }
             } catch (\Exception $e) {
             }
             return new DuplicateEntryException($e, $columns, $query, $params, $this);
         } elseif ($info[0] == 23000 && $info[1] == self::MYSQL_ERR_NOT_NULL) {
             // notnull fail
             $column = NULL;
             if (preg_match('~Column \'([^\']+)\'~', $info[2], $m)) {
                 $column = $m[1];
             }
             return new EmptyValueException($e, $column, $query, $params, $this);
         }
     }
     $raw = $e;
     do {
         $raw = $raw->getPrevious();
     } while ($raw && !$raw instanceof \PDOException);
     return new DBALException($e, $query, $params, $this, $raw ? $raw->getMessage() : $e->getMessage());
 }
开发者ID:LidskaSila,项目名称:Doctrine,代码行数:46,代码来源:Connection.php

示例6: throwableToArray

/**
 * Convert an Exception or Error into an array (for logging)
 *
 * @param \Throwable $ex
 * @return array
 */
function throwableToArray(\Throwable $ex) : array
{
    $prev = $ex->getPrevious();
    return ['line' => $ex->getLine(), 'file' => $ex->getFile(), 'message' => $ex->getMessage(), 'code' => $ex->getCode(), 'trace' => $ex->getTrace(), 'previous' => $prev ? throwableToArray($prev) : null];
}
开发者ID:paragonie,项目名称:airship,代码行数:11,代码来源:Airship.php

示例7: normalizeException

 protected function normalizeException(\Throwable $e, int $depth = 0) : string
 {
     $previousText = '';
     if ($previous = $e->getPrevious()) {
         do {
             $previousText .= ', ' . get_class($previous) . '(code: ' . $previous->getCode() . '): ' . $previous->getMessage() . ' at ' . $previous->getFile() . ':' . $previous->getLine();
         } while ($previous = $previous->getPrevious());
     }
     $str = '[object] (' . get_class($e) . '(code: ' . $e->getCode() . '): ' . $e->getMessage() . ' at ' . $e->getFile() . ':' . $e->getLine() . $previousText . ')';
     if ($this->includeStacktraces) {
         $str .= "\n[stacktrace]\n" . $e->getTraceAsString() . "\n";
     }
     return $str;
 }
开发者ID:earncef,项目名称:monolog,代码行数:14,代码来源:LineFormatter.php

示例8: echoPreviousExceptions

    /**
     * Echoes previous exceptions if applicable
     *
     * @author Art <a.molcanovas@gmail.com>
     *
     * @param null|\Throwable $e     The previous exception
     * @param int             $level How many previous exceptions have been echoed so far
     *
     * @codeCoverageIgnore
     */
    protected function echoPreviousExceptions($e, $level = 0)
    {
        if ($level < $this->config->prevExceptionDepth && $e) {
            if ($this->isCLI) {
                $this->console->write('<eb>Preceded by </>')->write('<e>[' . $e->getCode() . '] ' . $e->getMessage() . '</>')->write('<e> @ ' . $e->getFile() . '\'s line ' . $e->getLine() . '</>', true)->writeln('');
            } else {
                ?>
                    <div>
                        <span class="alo-bold">Preceded by </span>
                        <span>[<?php 
                echo $e->getCode();
                ?>
]: <?php 
                echo $e->getMessage();
                ?>
</span>
                        <span> @ </span>
                        <span class="alo-uline"><?php 
                echo $e->getFile();
                ?>
</span>
                        <span> @ line </span>
                        <span class="alo-uline"><?php 
                echo $e->getLine();
                ?>
                    </div>
                    <?php 
            }
            $this->echoPreviousExceptions($e->getPrevious(), ++$level);
        }
    }
开发者ID:aloframework,项目名称:handlers,代码行数:41,代码来源:ExceptionHandler.php


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