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


PHP Exception::getDetails方法代码示例

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


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

示例1: buildLogMessage

 /**
  * @param \Exception $exception
  *
  * @return string
  */
 protected function buildLogMessage(\Exception $exception)
 {
     $message = $exception->getMessage() . "({$exception->getCode()})";
     if ($exception instanceof PhprestException && $exception->getDetails()) {
         $message .= ' Details :: ' . json_encode($exception->getDetails());
     }
     $message .= ' Stack trace :: ' . $exception->getTraceAsString();
     return $message;
 }
开发者ID:phprest,项目名称:phprest,代码行数:14,代码来源:Log.php

示例2: testInstantiation

 public function testInstantiation()
 {
     $exception = new Exception('test message', 9, 201, [1, 2, 3]);
     $this->assertEquals('test message', $exception->getMessage());
     $this->assertEquals(9, $exception->getCode());
     $this->assertEquals(201, $exception->getStatusCode());
     $this->assertEquals([1, 2, 3], $exception->getDetails());
 }
开发者ID:phprest,项目名称:phprest,代码行数:8,代码来源:ExceptionTest.php

示例3: __construct

 /**
  * @param \Exception $exception
  */
 public function __construct(\Exception $exception)
 {
     $this->code = $exception->getCode();
     $this->message = $exception->getMessage();
     if ($exception instanceof Exception) {
         $this->details = $exception->getDetails();
     }
 }
开发者ID:phprest,项目名称:phprest,代码行数:11,代码来源:Error.php

示例4: displayError

 public function displayError(\Exception $exception)
 {
     $originalException = $exception;
     $code = $exception->getCode();
     //if extended exception was thrown, we have additional details
     if ($exception instanceof ExceptionInterface) {
         $httpStatus = $exception->getHttpStatus();
         $details = $exception->getDetails();
     } else {
         $httpStatus = 500;
         $details = array();
     }
     $development = ini_get('display_errors') && APPLICATION_ENV === "development";
     $message = $exception->getMessage();
     //determine whether this is an error the user should see
     if (($code < 100000 || $code >= 200000) && !$development) {
         //exception code is in the range where the message should be
         //displayed to the user
         $message = "An unexpected error has occurred";
         $details['detail'] = "This might be the developer's fault. The developer has been notified of this occurrence";
     }
     //show exception details if in development //redundant conditional?
     if ($development) {
         $exceptions = array();
         do {
             $exceptions['exception'][] = array('message' => $exception->getMessage(), 'code' => $exception->getCode(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => $exception->getTraceAsString());
         } while ($exception = $exception->getPrevious());
         $details['exceptions'] = $exceptions;
     }
     //TODO attach to this event, email if not in user visible range
     $this->getEventManager()->trigger('displayError', $this, $originalException);
     $result = $this->getError($message, $details, $httpStatus, $code);
     return $this->display($result);
 }
开发者ID:shinymayhem,项目名称:shiny-rest,代码行数:34,代码来源:AbstractRestfulController.php

示例5: processExceptionFromRPCCall

 private function processExceptionFromRPCCall(ClientSession $session, InvocationMessage $msg, $registration, \Exception $e)
 {
     if ($e instanceof WampErrorException) {
         $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg);
         $errorMsg->setErrorURI($e->getErrorUri());
         $errorMsg->setArguments($e->getArguments());
         $errorMsg->setArgumentsKw($e->getArgumentsKw());
         $errorMsg->setDetails($e->getDetails());
         $session->sendMessage($errorMsg);
         return;
     }
     $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg);
     $errorMsg->setErrorURI($registration['procedure_name'] . '.error');
     $errorMsg->setArguments([$e->getMessage()]);
     $errorMsg->setArgumentsKw($e);
     $session->sendMessage($errorMsg);
 }
开发者ID:WyriHaximus,项目名称:Thruway,代码行数:17,代码来源:Callee.php


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