From 88b6a1d6fae43c859bd91125702886f4d360f70c Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 16 Aug 2022 00:18:25 +0200 Subject: [PATCH] throw error type dependend exceptions --- .../Exceptions/CompileErrorException.php | 22 +++++++++++++++++++ .../Models/Exceptions/CoreErrorException.php | 22 +++++++++++++++++++ .../Models/Exceptions/ParseException.php | 22 +++++++++++++++++++ .../Models/Exceptions/UserErrorException.php | 22 +++++++++++++++++++ Modules/Core/ShopControl_DebugBar.php | 20 +++++++++++++++-- 5 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 Application/Models/Exceptions/CompileErrorException.php create mode 100644 Application/Models/Exceptions/CoreErrorException.php create mode 100644 Application/Models/Exceptions/ParseException.php create mode 100644 Application/Models/Exceptions/UserErrorException.php diff --git a/Application/Models/Exceptions/CompileErrorException.php b/Application/Models/Exceptions/CompileErrorException.php new file mode 100644 index 0000000..94e0d28 --- /dev/null +++ b/Application/Models/Exceptions/CompileErrorException.php @@ -0,0 +1,22 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +namespace D3\DebugBar\Application\Models\Exceptions; + +use ErrorException; + +class CompileErrorException extends ErrorException +{ +} \ No newline at end of file diff --git a/Application/Models/Exceptions/CoreErrorException.php b/Application/Models/Exceptions/CoreErrorException.php new file mode 100644 index 0000000..ef94370 --- /dev/null +++ b/Application/Models/Exceptions/CoreErrorException.php @@ -0,0 +1,22 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +namespace D3\DebugBar\Application\Models\Exceptions; + +use ErrorException; + +class CoreErrorException extends ErrorException +{ +} \ No newline at end of file diff --git a/Application/Models/Exceptions/ParseException.php b/Application/Models/Exceptions/ParseException.php new file mode 100644 index 0000000..28a6ca8 --- /dev/null +++ b/Application/Models/Exceptions/ParseException.php @@ -0,0 +1,22 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +namespace D3\DebugBar\Application\Models\Exceptions; + +use ErrorException; + +class ParseException extends ErrorException +{ +} \ No newline at end of file diff --git a/Application/Models/Exceptions/UserErrorException.php b/Application/Models/Exceptions/UserErrorException.php new file mode 100644 index 0000000..d4e62a8 --- /dev/null +++ b/Application/Models/Exceptions/UserErrorException.php @@ -0,0 +1,22 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +namespace D3\DebugBar\Application\Models\Exceptions; + +use ErrorException; + +class UserErrorException extends ErrorException +{ +} \ No newline at end of file diff --git a/Modules/Core/ShopControl_DebugBar.php b/Modules/Core/ShopControl_DebugBar.php index 62efe6c..a9da785 100644 --- a/Modules/Core/ShopControl_DebugBar.php +++ b/Modules/Core/ShopControl_DebugBar.php @@ -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 ); } }