本文整理汇总了PHP中Whoops\Exception\Formatter::formatExceptionAsDataArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Formatter::formatExceptionAsDataArray方法的具体用法?PHP Formatter::formatExceptionAsDataArray怎么用?PHP Formatter::formatExceptionAsDataArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Whoops\Exception\Formatter
的用法示例。
在下文中一共展示了Formatter::formatExceptionAsDataArray方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
public function handle()
{
if (!$this->isAjaxRequest()) {
return Handler::DONE;
}
$ex = $this->getException();
if ($ex instanceof UserException) {
$obj = ['message' => $ex->getMessage(), 'code' => $ex->getUserErrorCode(), 'status' => $ex->getCode()];
} else {
if ($this->debug) {
$obj = ['message' => $ex->getMessage(), 'code' => $ex->getCode(), 'status' => 500];
} else {
$obj = ['message' => 'Server internal error', 'code' => -1, 'status' => 500];
}
}
if ($this->debug) {
$obj['detail'] = Formatter::formatExceptionAsDataArray($this->getInspector(), true);
}
$this->getRun()->sendHttpCode($obj['status']);
if (Misc::canSendHeaders()) {
header('Content-Type: application/json');
}
echo json_encode($obj);
return Handler::QUIT;
}
示例2: handle
public function handle()
{
if (!$this->isAjaxRequest()) {
return Handler::DONE;
}
$display = Config::get('concrete.debug.display_errors');
if (!$display) {
$error = array('message' => t('An error occurred while processing this request.'));
} else {
$detail = Config::get('concrete.debug.detail', 'message');
if ($detail !== 'debug') {
$e = $this->getInspector()->getException();
$error = array('message' => $e->getMessage());
} else {
$error = Formatter::formatExceptionAsDataArray($this->getInspector(), true);
}
}
$response = array('error' => $error, 'errors' => array($error['message']));
if (Misc::canSendHeaders()) {
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
header('Content-Type: application/json; charset=' . APP_CHARSET, true);
} else {
header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
}
}
echo json_encode($response);
return Handler::QUIT;
}
示例3: handle
/**
* @return int
*/
public function handle()
{
$response = Formatter::formatExceptionAsDataArray($this->getInspector(), 1);
$viewModel = new ViewModel();
$viewModel->setTemplate('error/500');
$viewModel->setVariables($response);
echo $this->renderer->render($viewModel);
return \Whoops\Handler\Handler::QUIT;
}
示例4: handle
/**
* @return int
*/
public function handle()
{
$response = array('error' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
if (\Whoops\Util\Misc::canSendHeaders()) {
header('Content-Type: application/json');
}
echo json_encode($response, defined('JSON_PARTIAL_OUTPUT_ON_ERROR') ? JSON_PARTIAL_OUTPUT_ON_ERROR : 0);
return Handler::QUIT;
}
示例5: handle
/**
* @return int
*/
public function handle()
{
$response = array('error' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
$debug = $this->getDataTable();
if (count($debug) > 0) {
$response["debug"] = $debug;
}
echo json_encode($response, defined('JSON_PARTIAL_OUTPUT_ON_ERROR') ? JSON_PARTIAL_OUTPUT_ON_ERROR : 0);
return Handler::QUIT;
}
示例6: handle
/**
* @return int
*/
public function handle()
{
if ($this->onlyForAjaxRequests() && !$this->isAjaxRequest()) {
return Handler::DONE;
}
$response = array('error' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
if (\Whoops\Util\Misc::canSendHeaders()) {
header('Content-Type: application/json');
}
echo json_encode($response);
return Handler::QUIT;
}
示例7: handle
/**
* @return int
*/
public function handle()
{
if (!$this->isAjaxRequest()) {
return Handler::DONE;
}
$response = array('success' => false, 'data' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
if (Misc::canSendHeaders()) {
header('Content-Type: application/json; charset=' . get_option('blog_charset'));
}
$json_options = version_compare(PHP_VERSION, '5.4.0', '>=') ? JSON_PRETTY_PRINT : 0;
echo wp_json_encode($response, $json_options);
return Handler::QUIT;
}
示例8: handle
/**
* @return int
*/
public function handle()
{
if ($this->onlyForAjaxRequests() && !$this->isAjaxRequest()) {
return \Whoops\Handler\Handler::DONE;
}
if ($this->onlyForJsonRequests() && !$this->isJsonRequest()) {
return \Whoops\Handler\Handler::DONE;
}
$response = array('error' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
unset($response['error']['file']);
unset($response['error']['line']);
$response['error']['code'] = $this->getException()->getCode();
if (\Whoops\Util\Misc::canSendHeaders()) {
http_response_code($response['error']['code']);
header('Content-Type: application/json');
}
echo json_encode($response, defined('JSON_PARTIAL_OUTPUT_ON_ERROR') ? JSON_PARTIAL_OUTPUT_ON_ERROR : 0);
return \Whoops\Handler\Handler::QUIT;
}
示例9: handle
public function handle()
{
$debug = Config::get('concrete.debug.level', 0);
if ($debug !== DEBUG_DISPLAY_ERRORS) {
return Handler::DONE;
}
if (!$this->isAjaxRequest()) {
return Handler::DONE;
}
$error = Formatter::formatExceptionAsDataArray($this->getInspector(), true);
$response = array('error' => $error, 'errors' => array($error['message']));
if (\Whoops\Util\Misc::canSendHeaders()) {
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
header('Content-Type: application/json; charset=' . APP_CHARSET, true);
} else {
header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
}
}
echo json_encode($response);
return Handler::QUIT;
}
示例10: handle
/**
* @return int
*/
public function handle()
{
$response = array('error' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
echo $this->toXml($response);
return Handler::QUIT;
}
示例11: getData
public function getData($inspector)
{
//print_r($this->getInspector());exit();
$data = ['trace' => WhoopsFormatter::formatExceptionAsDataArray($inspector, $this->addTraceToOutput()), "GET Data" => $_GET, "POST Data" => $_POST, "Files" => $_FILES, "Cookies" => $_COOKIE, "Session" => isset($_SESSION) ? $_SESSION : [], "Server/Request Data" => $_SERVER, "Environment Variables" => $_ENV];
return $data;
}