/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Error
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Error/ConsoleErrorHandler.php (3830B)
$config Config options for the error handler.
*/
public function __construct(array $config = [])
{
$config += [
'stderr' => new ConsoleOutput('php://stderr'),
'log' => false,
];
$this->setConfig($config);
$this->_stderr = $this->_config['stderr'];
}
/**
* Handle errors in the console environment. Writes errors to stderr,
* and logs messages if Configure::read('debug') is false.
*
* @param \Throwable $exception Exception instance.
* @return void
* @throws \Exception When renderer class not found
* @see https://secure.php.net/manual/en/function.set-exception-handler.php
*/
public function handleException(Throwable $exception): void
{
$this->_displayException($exception);
$this->logException($exception);
$exitCode = Command::CODE_ERROR;
if ($exception instanceof ConsoleException) {
$exitCode = $exception->getCode();
}
$this->_stop($exitCode);
}
/**
* Prints an exception to stderr.
*
* @param \Throwable $exception The exception to handle
* @return void
*/
protected function _displayException(Throwable $exception): void
{
$errorName = 'Exception:';
if ($exception instanceof FatalErrorException) {
$errorName = 'Fatal Error:';
}
$message = sprintf(
"
%s %s\nIn [%s, line %s]\n",
$errorName,
$exception->getMessage(),
$exception->getFile(),
$exception->getLine()
);
$this->_stderr->write($message);
}
/**
* Prints an error to stderr.
*
* Template method of BaseErrorHandler.
*
* @param array $error An array of error data.
* @param bool $debug Whether the app is in debug mode.
* @return void
*/
protected function _displayError(array $error, bool $debug): void
{
$message = sprintf(
"%s\nIn [%s, line %s]",
$error['description'],
$error['file'],
$error['line']
);
$message = sprintf(
"
%s Error: %s\n",
$error['error'],
$message
);
$this->_stderr->write($message);
}
/**
* Stop the execution and set the exit code for the process.
*
* @param int $code The exit code.
* @return void
*/
protected function _stop(int $code): void
{
exit($code);
}
}
// phpcs:disable
class_alias(
'Cake\Error\ConsoleErrorHandler',
'Cake\Console\ConsoleErrorHandler'
);
// phpcs:enable