CoreFiles by mySites.guru
CliRenderer.php70 lines, 1,438 bytes, from Joomla_4.0.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 3.10.0-alpha9
md5
60c013f935b88df3db1c38cbc6a10649
sha1
0a0fde2190c45db7e36d57e04b2817ad84894c26
sha256
03bdf374f346debbc0cc5ac0eca1d0e71d4223f02a4b9af4d9f1a4584ecd9c79
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\CMS\Error\Renderer;

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Error\AbstractRenderer;

/**
 * Cli error renderer
 *
 * @since  __DEPLOY_VERSION__
 */
class CliRenderer extends AbstractRenderer
{
	/**
	 * The format (type)
	 *
	 * @var    string
	 * @since  __DEPLOY_VERSION__
	 */
	protected $type = 'cli';

	/**
	 * Render the error for the given object.
	 *
	 * @param   \Throwable  $error  The error object to be rendered
	 *
	 * @return  string
	 *
	 * @since   __DEPLOY_VERSION__
	 */
	public function render(\Throwable $error): string
	{
		$buffer = PHP_EOL . 'Error occurred: ' . $error->getMessage() . PHP_EOL . $this->getTrace($error);

		if ($prev = $error->getPrevious())
		{
			$buffer .= PHP_EOL . PHP_EOL . 'Previous Exception: ' . $prev->getMessage() . PHP_EOL . $this->getTrace($prev);
		}

		return $buffer;
	}

	/**
	 * Returns a trace for the given error.
	 *
	 * @param   \Throwable  $error  The error
	 *
	 * @return  string
	 *
	 * @since   __DEPLOY_VERSION__
	 */
	private function getTrace(\Throwable $error): string
	{
		// Include the stack trace only if in debug mode
		if (!JDEBUG)
		{
			return '';
		}

		return PHP_EOL . $error->getTraceAsString() . PHP_EOL;
	}
}

No other release has this exact content. See every version of this file.