本文整理汇总了PHP中Whoops\Run::popHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Run::popHandler方法的具体用法?PHP Run::popHandler怎么用?PHP Run::popHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Whoops\Run
的用法示例。
在下文中一共展示了Run::popHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable $next
*
* @return ResponseInterface
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{
try {
return $next($request, $response);
} catch (Exception $e) {
if ($this->logger) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
}
$type = $this->type($request);
$response = $response->withHeader('Content-Type', $type);
try {
if (method_exists($e, 'getHttpStatus')) {
$code = $e->getHttpStatus();
} else {
$code = $e->getCode();
}
$response = $response->withStatus($code);
} catch (InvalidArgumentException $_) {
// Exception did not contain a valid code
$response = $response->withStatus(500);
}
if ($e instanceof HttpException) {
$response = $e->withResponse($response);
}
$handler = $this->handler($type);
$this->whoops->pushHandler($handler);
$body = $this->whoops->handleException($e);
$response->getBody()->write($body);
$this->whoops->popHandler();
return $response;
}
}
示例2: setHandler
/**
* Set the proper Error Handler based on the Output of the page
*
* @param string $output
*/
public function setHandler($output = null)
{
$this->_whoops->popHandler();
if ($output == Output::JSON) {
$this->_handler = new JsonResponseHandler();
} else {
if ($output == Output::XML) {
$this->_handler = new XmlResponseHandler();
} else {
$this->_handler = new PlainResponseHandler();
}
}
$this->_whoops->pushHandler($this->_handler);
}
示例3: setHandler
/**
* Set the proper Error Handler based on the Output of the page
*
* @param OutputData $output
*/
public function setHandler($output)
{
$this->_whoops->popHandler();
if ($output == OutputData::Json) {
$this->_handler = new JsonResponseHandler();
} else {
if ($output == OutputData::Xml) {
$this->_handler = new XmlResponseHandler();
} else {
$this->_handler = new PrettyPageHandler();
if (!Context::getInstance()->getDevelopmentStatus()) {
$this->_handler->addResourcePath(\WhoopsResources\Resource::getPath());
}
}
}
$this->_whoops->pushHandler($this->_handler);
}
示例4: __invoke
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable $next
*
* @return ResponseInterface
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{
try {
return $next($request, $response);
} catch (Exception $e) {
$type = $this->type($request);
$response = $response->withHeader('Content-Type', $type);
try {
$response = $response->withStatus($e->getCode());
} catch (InvalidArgumentException $_) {
// Exception did not contain a valid code
$response = $response->withStatus(500);
}
if ($e instanceof HttpException) {
$response = $e->withResponse($response);
}
$handler = $this->handler($type);
$this->whoops->pushHandler($handler);
$body = $this->whoops->handleException($e);
$response->getBody()->write($body);
$this->whoops->popHandler();
return $response;
}
}
示例5: popHandler
/**
* Pops the last handler
*/
public function popHandler()
{
$this->errorHandler->popHandler();
}