throw error type dependend exceptions

This commit is contained in:
Daniel Seifert 2022-08-16 00:18:25 +02:00
parent 236680ad7a
commit 88b6a1d6fa
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
5 changed files with 106 additions and 2 deletions

View File

@ -0,0 +1,22 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DebugBar\Application\Models\Exceptions;
use ErrorException;
class CompileErrorException extends ErrorException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DebugBar\Application\Models\Exceptions;
use ErrorException;
class CoreErrorException extends ErrorException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DebugBar\Application\Models\Exceptions;
use ErrorException;
class ParseException extends ErrorException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DebugBar\Application\Models\Exceptions;
use ErrorException;
class UserErrorException extends ErrorException
{
}

View File

@ -16,6 +16,10 @@ declare(strict_types=1);
namespace D3\DebugBar\Modules\Core;
use D3\DebugBar\Application\Component\DebugBarComponent;
use D3\DebugBar\Application\Models\Exceptions\CompileErrorException;
use D3\DebugBar\Application\Models\Exceptions\CoreErrorException;
use D3\DebugBar\Application\Models\Exceptions\ParseException;
use D3\DebugBar\Application\Models\Exceptions\UserErrorException;
use D3\DebugBar\Core\DebugBarExceptionHandler;
use DebugBar\DataCollector\ExceptionsCollector;
use ErrorException;
@ -55,9 +59,21 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
[ $file, $line ] = $smartyTemplate;
}
throw new ErrorException( $message, 0, $severity, $file, $line );
switch($severity) {
case E_CORE_ERROR:
throw new CoreErrorException($message, 0, $severity, $file, $line);
case E_COMPILE_ERROR:
throw new CompileErrorException($message, 0, $severity, $file, $line);
case E_USER_ERROR:
throw new UserErrorException($message, 0, $severity, $file, $line);
case E_PARSE:
throw new ParseException($message, 0, $severity, $file, $line);
case E_ERROR:
default:
throw new ErrorException($message, 0, $severity, $file, $line);
}
},
E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR
E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_PARSE
);
}
}