本文整理汇总了PHP中Exception::getRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getRequest方法的具体用法?PHP Exception::getRequest怎么用?PHP Exception::getRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromException
/**
* @param \Exception $exception
* @return GuzzleRestException
*/
public static function createFromException(\Exception $exception)
{
if ($exception instanceof BadResponseException && $exception->getResponse()) {
$url = $exception->getRequest() ? (string) $exception->getRequest()->getUrl() : null;
$result = GuzzleRestException::createFromResponse(new GuzzleRestResponse($exception->getResponse(), $url), null, $exception);
} else {
/** @var GuzzleRestException $result */
$result = new static($exception->getMessage(), $exception->getCode(), $exception);
}
return $result;
}
示例2: factory
public static function factory($name, \Exception $exception)
{
$message = sprintf("%s could not be found. The API returned this HTTP response:\n\n%s", $name, (string) $exception->getResponse());
$e = new self($message);
$e->name = $name;
$e->response = $exception->getResponse();
$e->request = $exception->getRequest();
return $e;
}
示例3: renderException
/**
* @param \Exception $e
*
* @return array
*/
public static function renderException($e)
{
$click = function ($o, $c = TRUE) {
return Dumper::toHtml($o, array('collapse' => $c));
};
$panel = array();
if ($e instanceof Curl\FailedRequestException) {
$panel['info'] = '<h3>Info</h3>' . $click($e->getInfo(), TRUE);
}
if ($e instanceof Curl\CurlException) {
if ($e->getRequest()) {
$panel['request'] = '<h3>Request</h3>' . $click($e->getRequest(), TRUE);
}
if ($e->getResponse()) {
$panel['response'] = '<h3>Responses</h3>' . static::allResponses($e->getResponse());
}
}
if (!empty($panel)) {
return array('tab' => 'Curl', 'panel' => implode($panel));
}
}
示例4: renderException
/**
* @param \Exception|\Throwable $e
* @return array|NULL
*/
public static function renderException($e = NULL)
{
if (!$e instanceof ExceptionInterface) {
return NULL;
}
$panel = NULL;
if ($e instanceof Elastica\Exception\ResponseException) {
$panel .= '<h3>Request</h3>';
$panel .= Dumper::toHtml($e->getRequest());
$panel .= '<h3>Response</h3>';
$panel .= Dumper::toHtml($e->getResponse());
} elseif ($e instanceof Elastica\Exception\Bulk\ResponseException) {
$panel .= '<h3>Failures</h3>';
$panel .= Dumper::toHtml($e->getFailures());
}
/*elseif ($e->getQuery() !== NULL) {
$panel .= '<h3>Query</h3>'
. '<pre class="nette-dump"><span class="php-string">'
. $e->getQuery()->getQuery()
. '</span></pre>';
} */
return $panel ? array('tab' => 'ElasticSearch', 'panel' => $panel) : NULL;
}