本文整理汇总了PHP中Exception::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getTitle方法的具体用法?PHP Exception::getTitle怎么用?PHP Exception::getTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getTitle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render an HTML error page from an exception.
*
* @param Exception $exception
* @param Mad_Controller_Request_Http $request
* @param Mad_Controller_Response_Http $response
*/
public function render($exception, $request, $response)
{
// If there is anything leftover in the output buffer, such
// as interrupted template rendering, destroy it.
while (ob_get_level()) {
ob_get_clean();
}
// title
if ($exception instanceof Mad_Support_Exception) {
$title = $exception->getTitle();
} else {
$title = get_class($exception);
}
// message
if (!strlen($message = $exception->getMessage())) {
$message = "<no message>";
}
// assignments
$this->_view->title = $title;
$this->_view->message = $message;
$this->_view->exception = $exception;
$this->_view->trace = $this->formatTrace($exception);
$this->_view->request = $request;
$this->_view->response = $response;
$this->_view->extraction = $this->extractSource($exception);
// render the error page contents
$this->_view->contents = $this->_view->render('diagnostics');
// render the error layout
$html = $this->_view->render('layout');
return $html;
}
示例2: handleRequestException
public function handleRequestException(AphrontRequest $request, Exception $ex)
{
$viewer = $this->getViewer($request);
if (!$viewer->isLoggedIn()) {
// If the user isn't logged in, just give them a login form. This is
// probably a generally more useful response than a policy dialog that
// they have to click through to get a login form.
//
// Possibly we should add a header here like "you need to login to see
// the thing you are trying to look at".
$auth_app_class = 'PhabricatorAuthApplication';
$auth_app = PhabricatorApplication::getByClass($auth_app_class);
return id(new PhabricatorAuthStartController())->setRequest($request)->setCurrentApplication($auth_app)->handleRequest($request);
}
$content = array(phutil_tag('div', array('class' => 'aphront-policy-rejection'), $ex->getRejection()));
$list = null;
if ($ex->getCapabilityName()) {
$list = $ex->getMoreInfo();
foreach ($list as $key => $item) {
$list[$key] = $item;
}
$content[] = phutil_tag('div', array('class' => 'aphront-capability-details'), pht('Users with the "%s" capability:', $ex->getCapabilityName()));
}
$dialog = id(new AphrontDialogView())->setTitle($ex->getTitle())->setClass('aphront-access-dialog')->setUser($viewer)->appendChild($content);
if ($list) {
$dialog->appendList($list);
}
if ($request->isAjax()) {
$dialog->addCancelButton('/', pht('Close'));
} else {
$dialog->addCancelButton('/', pht('OK'));
}
return $dialog;
}
示例3: logException
/**
* Schreibt die Exception in eine Log-Datei
*
* @param Exception $e Exceptionklasse
*/
public static function logException($e, $title = null, $comment = null)
{
date_default_timezone_set("Europe/Zurich");
$time = date("Y-m-d H:i");
if (empty($title)) {
$title = $e->getTitle();
}
$rpcl_arr = array("\t" => " ", "\n" => " ", "\r" => " ", "\\xOB" => " ");
$file = $e->getFile();
$code = $e->getCode();
$msg = strtr($e->getMessage(), $rpcl_arr);
$line = $e->getLine();
$trace = strtr($e->getTraceAsString(), $rpcl_arr);
if (!empty($comment)) {
$comment = strtr($comment, $rpcl_arr);
}
if (key_exists('HTTP_POST_VARS', $GLOBALS)) {
$post = strtr(print_r($GLOBALS['HTTP_POST_VARS'], 1), $rpcl_arr);
} else {
$post = "POST_VARS ARE NOT AVAILABLE";
}
if (key_exists('HTTP_GET_VARS', $GLOBALS)) {
$get = strtr(print_r($GLOBALS['HTTP_GET_VARS'], 1), $rpcl_arr);
} else {
$get = "GET_VARS ARE NOT AVAILABLE";
}
/* Log schreiben */
$fh = fopen(ADMIN_DIR . "log/.exception.log", "a");
$log_line = "#LOG-ENTRY\nTITLE: {$title}\nCODE: {$code}\nTIME: {$time}\nFILE: {$file}\nLINE: {$line}\nMESSAGE: {$msg}\n" . "TRACE: {$trace}\nPOST: {$post}\nGET: {$get}\nCOMMENT: {$comment}\n#END\n\n";
fputs($fh, $log_line);
fclose($fh);
}