Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/Config/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ class Exceptions extends BaseConfig
*/
public $ignoreCodes = [404];

/**
* --------------------------------------------------------------------------
* DO NOT FAIL ON DEPRECATIONS
* --------------------------------------------------------------------------
* By default deprecation errors will be thrown as exception stopping
* the framework from further code execution. With this parameter set to
* true the deprecations will not throw exception but instead will be written
* to the log with warning level.
*
* @var bool
*/
public $failOnDeprecated = true;

/**
* --------------------------------------------------------------------------
* Error Views Path
Expand Down
14 changes: 14 additions & 0 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ public function exceptionHandler(Throwable $exception)
*/
public function errorHandler(int $severity, string $message, ?string $file = null, ?int $line = null)
{
if ($this->config->failOnDeprecated !== true && $severity === E_DEPRECATED) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isset failOnDeprecated property exist should be applied

if ($this->config->log === true) {
$exception = new ErrorException($message, 0, $severity, $file, $line);
log_message('warning', "{message}\nin {exFile} on line {exLine}.\n{trace}", [
'message' => $exception->getMessage(),
'exFile' => clean_path($exception->getFile()), // {file} refers to THIS file
'exLine' => $exception->getLine(), // {line} refers to THIS line
'trace' => self::renderBacktrace($exception->getTrace()),
]);
}

return;
}

if (! (error_reporting() & $severity)) {
return;
}
Expand Down