本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Console\Application::renderException方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::renderException方法的具体用法?PHP Application::renderException怎么用?PHP Application::renderException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Console\Application
的用法示例。
在下文中一共展示了Application::renderException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderException
public function renderException($e, $output)
{
// Send exception to Bugsnag
\Bugsnag::notifyException($e);
// Call parent function
parent::renderException($e, $output);
}
示例2: renderException
public function renderException($e, $output)
{
parent::renderException($e, $output);
$strlen = function ($string) {
if (!function_exists('mb_strlen')) {
return strlen($string);
}
if (false === ($encoding = mb_detect_encoding($string))) {
return strlen($string);
}
return mb_strlen($string, $encoding);
};
$log_message = '';
do {
$title = sprintf("Exception occured: [%s]\n", get_class($e));
$len = $strlen($title);
$lines = array();
foreach (explode("\n", $e->getMessage()) as $line) {
$lines[] = sprintf(' %s ', $line);
$len = max($strlen($line) + 4, $len);
}
$log_message .= $title;
foreach ($lines as $line) {
$log_message .= " " . $line . str_repeat(' ', $len - $strlen($line)) . "\n";
}
$log_message .= " Exception trace:\n";
// exception related properties
$trace = $e->getTrace();
array_unshift($trace, array('function' => '', 'file' => $e->getFile() != null ? $e->getFile() : 'n/a', 'line' => $e->getLine() != null ? $e->getLine() : 'n/a', 'args' => array()));
for ($i = 0, $count = count($trace); $i < $count; $i++) {
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
$function = $trace[$i]['function'];
$file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
$log_message .= sprintf(" %s%s%s() at %s:%s\n", $class, $type, $function, $file, $line);
}
} while ($e = $e->getPrevious());
error_log($log_message);
}