本文整理汇总了PHP中Throwable::getStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Throwable::getStatus方法的具体用法?PHP Throwable::getStatus怎么用?PHP Throwable::getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Throwable
的用法示例。
在下文中一共展示了Throwable::getStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderBeautifulExceptionView
/**
* Sends a nice detailed view to the Response
*
* @param \Exception $e
*/
private function renderBeautifulExceptionView(\Throwable $e)
{
$request = N2N::getCurrentRequest();
$response = N2N::getCurrentResponse();
$status = null;
$viewName = null;
if ($e instanceof StatusException) {
$status = $e->getStatus();
} else {
$status = Response::STATUS_500_INTERNAL_SERVER_ERROR;
}
$throwableModel = null;
// if ($e instanceof StatusException && isset($viewName)) {
// $throwableModel = new ThrowableModel($e, null);
// } else {
$throwableModel = new ThrowableModel($e);
$this->pendingOutputs[] = $response->fetchBufferedOutput(false);
$that = $this;
$throwableModel->setOutputCallback(function () use($that) {
$output = implode('', $this->pendingOutputs);
$this->pendingOutputs = array();
return $output;
});
// }
$viewName = N2N::getAppConfig()->error()->getErrorViewName($status);
if ($viewName === null) {
if (!N2N::isDevelopmentModeOn()) {
$viewName = self::DEFAULT_STATUS_LIVE_VIEW;
} else {
if ($status == Response::STATUS_500_INTERNAL_SERVER_ERROR) {
$viewName = self::DEFAULT_500_DEV_VIEW;
} else {
$viewName = self::DEFAULT_STATUS_DEV_VIEW;
}
}
}
$view = N2N::getN2nContext()->lookup(ViewFactory::class)->create($viewName, array('throwableModel' => $throwableModel));
$view->setControllerContext(new ControllerContext($request->getCmdPath(), $request->getCmdContextPath()));
$response->reset();
$response->setStatus($status);
$response->send($view);
}