本文整理汇总了PHP中Throwable::getErrorName方法的典型用法代码示例。如果您正苦于以下问题:PHP Throwable::getErrorName方法的具体用法?PHP Throwable::getErrorName怎么用?PHP Throwable::getErrorName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Throwable
的用法示例。
在下文中一共展示了Throwable::getErrorName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderException
/**
* @param \Exception|\Throwable $exception
*/
private function renderException($exception)
{
if ($exception instanceof ErrorException) {
fwrite(STDERR, sprintf("ErrorException: %s \n", $exception->getErrorName()));
} else {
fwrite(STDERR, sprintf("Exception: %s (Code: %d)\n", get_class($exception), $exception->getCode()));
}
fwrite(STDERR, sprintf("Location: %s (Line %d)\n\n", $exception->getFile(), $exception->getLine()));
fwrite(STDERR, $exception->getMessage() . "\n\n");
if ($exception instanceof HasFileInfoException) {
fwrite(STDERR, "\nException occured while processing file: " . $exception->getFile() . "\n\n");
}
$trace = $exception->getTrace();
array_shift($trace);
if (count($trace) == 0) {
fwrite(STDERR, 'No stacktrace available');
}
foreach ($trace as $pos => $entry) {
fwrite(STDERR, sprintf('#%1$d %2$s(%3$d): %4$s%5$s%6$s()' . "\n", $pos, isset($entry['file']) ? $entry['file'] : 'unknown', isset($entry['line']) ? $entry['line'] : '0', isset($entry['class']) ? $entry['class'] : '', isset($entry['type']) ? $entry['type'] : '', isset($entry['function']) ? $entry['function'] : ''));
}
$nested = $exception->getPrevious();
if ($nested !== NULL) {
fwrite(STDERR, "\n\n");
$this->renderException($nested);
}
}