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


PHP Exception::getName方法代码示例

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


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

示例1: getExceptionName

 /**
  * Returns human-readable exception name
  * @param \Exception $exception
  * @return string human-readable exception name or null if it cannot be determined
  */
 public function getExceptionName($exception)
 {
     if ($exception instanceof \yii\base\Exception || $exception instanceof \yii\base\InvalidCallException || $exception instanceof \yii\base\InvalidParamException || $exception instanceof \yii\base\UnknownMethodException) {
         return $exception->getName();
     }
     return null;
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:12,代码来源:ErrorHandler.php

示例2: convertExceptionToString

 /**
  * Converts an exception into a simple string.
  * @param \Exception $exception the exception being converted
  * @return string the string representation of the exception.
  */
 public static function convertExceptionToString($exception)
 {
     if ($exception instanceof Exception && ($exception instanceof UserException || !YII_DEBUG)) {
         $message = "{$exception->getName()}: {$exception->getMessage()}";
     } elseif (YII_DEBUG) {
         if ($exception instanceof Exception) {
             $message = "Exception ({$exception->getName()})";
         } elseif ($exception instanceof MyErrorException) {
             $message = "{$exception->getName()}";
         } else {
             $message = 'Exception';
         }
         $message .= " '" . get_class($exception) . "' with message '{$exception->getMessage()}' \n\nin " . $exception->getFile() . ':' . $exception->getLine() . "\n\n" . "Stack trace:\n" . $exception->getTraceAsString();
     } else {
         $message = 'Error: ' . $exception->getMessage();
     }
     return $message;
 }
开发者ID:DeDoOozZz,项目名称:brighterycms,代码行数:23,代码来源:ErrorHandler.php

示例3: renderException

 /**
  * Renders the exception.
  *
  * Note: This implementation renders the message in plain text. For HTML or ANSI consoles you might override this
  * method.
  *
  * @param \Exception $exception The exception to be rendered.
  */
 protected function renderException($exception)
 {
     if ($this->myDebug) {
         if ($exception instanceof ErrorException) {
             $message = $exception->getName();
         } elseif ($exception instanceof NamedException) {
             $message = "Exception ({$exception->getName()})";
         } else {
             $message = 'Exception';
         }
         $message .= " '" . get_class($exception) . "'";
         $message .= ' with message ' . $exception->getMessage();
         $message .= "\n\n";
         $message .= "in " . $exception->getFile() . ':' . $exception->getLine() . "\n";
         $message .= "\n";
         $message .= "Stack trace:\n";
         $message .= $exception->getTraceAsString();
     } elseif ($exception instanceof NamedException) {
         $message = $exception->getName() . ': ' . $exception->getMessage();
     } else {
         $message = 'Error: ' . $exception->getMessage();
     }
     echo $message, "\n";
 }
开发者ID:setbased,项目名称:php-affirm,代码行数:32,代码来源:ErrorHandler.php

示例4: convertExceptionToArray

 /**
  * Converts an exception into an array.
  * @param \Exception $exception the exception being converted
  * @return array the array representation of the exception.
  */
 protected function convertExceptionToArray($exception)
 {
     $array = ['error' => []];
     if ($exception instanceof HttpException) {
         if ($exception->params) {
             $array['error']['params'] = $exception->params;
         }
         if (isset(Application::$httpTypes[$exception->statusCode])) {
             $array['error']['type'] = Application::$httpTypes[$exception->statusCode];
         }
     }
     $array['error']['message'] = $exception->getMessage();
     if (empty($array['error']['type'])) {
         if ($exception instanceof HttpException) {
             $array['debug']['status'] = $exception->statusCode;
         }
         $name = 'Exception';
         if ($exception instanceof Exception || $exception instanceof ErrorException) {
             $name = $exception->getName();
         }
         $array['debug']['name'] = $name;
         $array['debug']['code'] = $exception->getCode();
         $array['debug']['type'] = get_class($exception);
         $array['debug']['file'] = $exception->getFile();
         $array['debug']['line'] = $exception->getLine();
         $array['debug']['stack-trace'] = explode("\n", $exception->getTraceAsString());
     }
     if (($prev = $exception->getPrevious()) !== null) {
         $array['previous'] = $this->convertExceptionToArray($prev);
     }
     return $array;
 }
开发者ID:phantom-d,项目名称:shop-cart,代码行数:37,代码来源:ErrorHandler.php


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