From f313732eb5597eac6105c912af6d1894050fac32 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 4 Jul 2022 12:13:49 +0900 Subject: [PATCH] feat: add HTTPExceptionInterface and ExitExceptionInterface --- .../Database/Exceptions/DatabaseException.php | 3 ++- system/Exceptions/CastException.php | 2 +- system/Exceptions/ConfigException.php | 2 +- system/Exceptions/ExitExceptionInterface.php | 19 +++++++++++++++++++ system/Exceptions/HTTPExceptionInterface.php | 19 +++++++++++++++++++ system/Exceptions/PageNotFoundException.php | 2 +- .../Router/Exceptions/RedirectException.php | 3 ++- 7 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 system/Exceptions/ExitExceptionInterface.php create mode 100644 system/Exceptions/HTTPExceptionInterface.php diff --git a/system/Database/Exceptions/DatabaseException.php b/system/Database/Exceptions/DatabaseException.php index 13f58dc129..92f72db412 100644 --- a/system/Database/Exceptions/DatabaseException.php +++ b/system/Database/Exceptions/DatabaseException.php @@ -11,9 +11,10 @@ namespace CodeIgniter\Database\Exceptions; +use CodeIgniter\Exceptions\HasExitCodeException; use Error; -class DatabaseException extends Error implements ExceptionInterface +class DatabaseException extends Error implements ExceptionInterface, HasExitCodeException { /** * Exit status code diff --git a/system/Exceptions/CastException.php b/system/Exceptions/CastException.php index 06511f7390..9598923e7b 100644 --- a/system/Exceptions/CastException.php +++ b/system/Exceptions/CastException.php @@ -18,7 +18,7 @@ namespace CodeIgniter\Exceptions; * * @codeCoverageIgnore */ -class CastException extends CriticalError +class CastException extends CriticalError implements HasExitCodeException { use DebugTraceableTrait; diff --git a/system/Exceptions/ConfigException.php b/system/Exceptions/ConfigException.php index ced8afc6e0..3b2867ed1c 100644 --- a/system/Exceptions/ConfigException.php +++ b/system/Exceptions/ConfigException.php @@ -14,7 +14,7 @@ namespace CodeIgniter\Exceptions; /** * Exception for automatic logging. */ -class ConfigException extends CriticalError +class ConfigException extends CriticalError implements HasExitCodeException { use DebugTraceableTrait; diff --git a/system/Exceptions/ExitExceptionInterface.php b/system/Exceptions/ExitExceptionInterface.php new file mode 100644 index 0000000000..e46d97d0fc --- /dev/null +++ b/system/Exceptions/ExitExceptionInterface.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace CodeIgniter\Exceptions; + +/** + * Interface for Exceptions that has exception code as exit code. + */ +interface ExitExceptionInterface +{ +} diff --git a/system/Exceptions/HTTPExceptionInterface.php b/system/Exceptions/HTTPExceptionInterface.php new file mode 100644 index 0000000000..901f0b6ca3 --- /dev/null +++ b/system/Exceptions/HTTPExceptionInterface.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace CodeIgniter\Exceptions; + +/** + * Interface for Exceptions that has exception code as HTTP status code. + */ +interface HTTPExceptionInterface +{ +} diff --git a/system/Exceptions/PageNotFoundException.php b/system/Exceptions/PageNotFoundException.php index 7546ddaa07..3206469663 100644 --- a/system/Exceptions/PageNotFoundException.php +++ b/system/Exceptions/PageNotFoundException.php @@ -14,7 +14,7 @@ namespace CodeIgniter\Exceptions; use Config\Services; use OutOfBoundsException; -class PageNotFoundException extends OutOfBoundsException implements ExceptionInterface +class PageNotFoundException extends OutOfBoundsException implements ExceptionInterface, HasHttpStatusCodeException { use DebugTraceableTrait; diff --git a/system/Router/Exceptions/RedirectException.php b/system/Router/Exceptions/RedirectException.php index d5a1616b48..340f6fdf18 100644 --- a/system/Router/Exceptions/RedirectException.php +++ b/system/Router/Exceptions/RedirectException.php @@ -11,12 +11,13 @@ namespace CodeIgniter\Router\Exceptions; +use CodeIgniter\Exceptions\HasHttpStatusCodeException; use Exception; /** * RedirectException */ -class RedirectException extends Exception +class RedirectException extends Exception implements HasHttpStatusCodeException { /** * HTTP status code for redirects