本文整理汇总了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;
}
示例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());
}
示例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();
}
}
示例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);
}
示例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);
}