Skip to content

Commit

Permalink
feat: add HasExitCodeException and HasHttpStatusCodeException Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jul 22, 2022
1 parent ba26fcc commit eda0ca8
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 5 deletions.
3 changes: 2 additions & 1 deletion system/Database/Exceptions/DatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion system/Exceptions/CastException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @codeCoverageIgnore
*/
class CastException extends CriticalError
class CastException extends CriticalError implements HasExitCodeException
{
use DebugTraceableTrait;

Expand Down
2 changes: 1 addition & 1 deletion system/Exceptions/ConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Exception for automatic logging.
*/
class ConfigException extends CriticalError
class ConfigException extends CriticalError implements HasExitCodeException
{
use DebugTraceableTrait;

Expand Down
19 changes: 19 additions & 0 deletions system/Exceptions/HasExitCodeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* 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 HasExitCodeException
{
}
19 changes: 19 additions & 0 deletions system/Exceptions/HasHttpStatusCodeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* 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 HasHttpStatusCodeException
{
}
2 changes: 1 addition & 1 deletion system/Exceptions/PageNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Config\Services;
use OutOfBoundsException;

class PageNotFoundException extends OutOfBoundsException implements ExceptionInterface
class PageNotFoundException extends OutOfBoundsException implements ExceptionInterface, HasHttpStatusCodeException
{
use DebugTraceableTrait;

Expand Down
3 changes: 2 additions & 1 deletion system/Router/Exceptions/RedirectException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
* Status code for redirects
Expand Down

0 comments on commit eda0ca8

Please sign in to comment.