throw error exceptions on error levels only

This commit is contained in:
Daniel Seifert 2022-08-15 23:40:50 +02:00
parent ff606efef3
commit 236680ad7a
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
1 changed files with 14 additions and 11 deletions

View File

@ -43,19 +43,22 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
public function d3DebugBarSetErrorHandler()
{
if ($this->d3CanActivateDebugBar()) {
set_error_handler( function( $severity, $message, $file, $line ) {
if ( ! ( error_reporting() & $severity ) ) {
// This error code is not included in error_reporting.
return;
}
set_error_handler(
function( $severity, $message, $file, $line ) {
if ( 0 === error_reporting() || !( error_reporting() & $severity ) ) {
// This error code is not included in error_reporting.
return false;
}
$smartyTemplate = $this->getSmartyTemplateLocationFromError( $message );
if ( is_array( $smartyTemplate ) ) {
[ $file, $line ] = $smartyTemplate;
}
$smartyTemplate = $this->getSmartyTemplateLocationFromError( $message );
if ( is_array( $smartyTemplate ) ) {
[ $file, $line ] = $smartyTemplate;
}
throw new ErrorException( $message, 0, $severity, $file, $line );
} );
throw new ErrorException( $message, 0, $severity, $file, $line );
},
E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR
);
}
}