Skip to content

fix: Exception rework #8728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2f72086
feat: add base RuntimeException and LogicException
kenjis Jan 27, 2024
50c43a3
feat: add BadMethodCallException,BadFunctionCallException,InvalidArgu…
kenjis Jan 27, 2024
085eb2d
refactor: FrameworkException extends RuntimeException
kenjis Jan 27, 2024
5178dd1
feat: extends ExceptionInterface
kenjis Jan 27, 2024
9d2c903
refactor: change parent class
kenjis Jan 27, 2024
8e5e207
refactor: remove unneeded `implements ExceptionInterface`
kenjis Jan 27, 2024
2087c55
fix: parent exception classes
kenjis Jan 27, 2024
3540f97
refactor: use CodeIgniter\Exceptions\RuntimeException
kenjis Jan 27, 2024
049fb2b
refactor: use CodeIgniter\Exceptions\InvalidArgumentException
kenjis Jan 27, 2024
4b8a50e
refactor: use CodeIgniter\Exceptions\LogicException
kenjis Jan 27, 2024
13106b8
refactor: use CodeIgniter\Exceptions\BadMethodCallException
kenjis Jan 27, 2024
82eaa32
refactor: use CodeIgniter\Exceptions\BadFunctionCallException
kenjis Jan 27, 2024
3fa8a26
fix: replace \Exception with RuntimeException
kenjis Jan 27, 2024
3a35769
fix: replace \Exception with BadMethodCallException
kenjis Jan 27, 2024
d33d3c7
fix: replace \TypeError with InvalidArgumentException
kenjis Jan 27, 2024
08fea02
docs: fix class Doc comments
kenjis Jan 28, 2024
616e0f5
test: update expectException()
kenjis Jan 28, 2024
832c77f
refactor: remove unneeded `implements ExceptionInterface`
kenjis Jan 28, 2024
b91b905
feat: add domain-level ExceptionInterface
kenjis Jan 28, 2024
cff68f1
feat: implements domain-level ExceptionInterface
kenjis Jan 28, 2024
fa0fea5
refactor: use CodeIgniter\Exceptions\InvalidArgumentException
kenjis Jan 29, 2024
8e75308
test: use odeIgniter\Exceptions\RuntimeException
kenjis Jan 29, 2024
8de2d70
test: use CodeIgniter\Exceptions\InvalidArgumentException
kenjis Jan 29, 2024
29b8597
test: use CodeIgniter\Exceptions\LogicException
kenjis Jan 29, 2024
aae19e6
test: use CodeIgniter\Exceptions\BadMethodCallException
kenjis Jan 29, 2024
ac9a716
test: use narrower exceptions
kenjis Jan 29, 2024
afe9968
refactor: use CodeIgniter\Exceptions\InvalidArgumentException
kenjis Jan 29, 2024
5512815
refactor: use CodeIgniter\Exceptions\RuntimeException
kenjis Jan 29, 2024
99e2ba3
refactor: use CodeIgniter\Exceptions\RuntimeException
kenjis Apr 16, 2024
60fddfe
refactor: use CodeIgniter\Exceptions\InvalidArgumentException
kenjis Apr 16, 2024
f1359dd
docs: add user guide
kenjis Apr 16, 2024
e1d3516
refactor: by rector
kenjis May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
namespace CodeIgniter\Autoloader;

use CodeIgniter\Exceptions\ConfigException;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\Exceptions\RuntimeException;
use Composer\Autoload\ClassLoader;
use Composer\InstalledVersions;
use Config\Autoload;
use Config\Kint as KintConfig;
use Config\Modules;
use Config\Services;
use InvalidArgumentException;
use Kint;
use Kint\Renderer\CliRenderer;
use Kint\Renderer\RichRenderer;
use RuntimeException;

/**
* An autoloader that uses both PSR4 autoloading, and traditional classmaps.
Expand Down
2 changes: 1 addition & 1 deletion system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
use CodeIgniter\Database\Query;
use CodeIgniter\DataConverter\DataConverter;
use CodeIgniter\Entity\Entity;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\Exceptions\ModelException;
use CodeIgniter\I18n\Time;
use CodeIgniter\Pager\Pager;
use CodeIgniter\Validation\ValidationInterface;
use Config\Feature;
use Config\Services;
use InvalidArgumentException;
use ReflectionClass;
use ReflectionException;
use ReflectionProperty;
Expand Down
2 changes: 1 addition & 1 deletion system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace CodeIgniter\CLI;

use CodeIgniter\CLI\Exceptions\CLIException;
use CodeIgniter\Exceptions\InvalidArgumentException;
use Config\Services;
use InvalidArgumentException;
use Throwable;

/**
Expand Down
2 changes: 1 addition & 1 deletion system/CLI/Exceptions/CLIException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace CodeIgniter\CLI\Exceptions;

use CodeIgniter\Exceptions\DebugTraceableTrait;
use RuntimeException;
use CodeIgniter\Exceptions\RuntimeException;

/**
* CLIException
Expand Down
5 changes: 2 additions & 3 deletions system/Cache/Exceptions/CacheException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
namespace CodeIgniter\Cache\Exceptions;

use CodeIgniter\Exceptions\DebugTraceableTrait;
use CodeIgniter\Exceptions\ExceptionInterface;
use RuntimeException;
use CodeIgniter\Exceptions\RuntimeException;

/**
* CacheException
*/
class CacheException extends RuntimeException implements ExceptionInterface
class CacheException extends RuntimeException
{
use DebugTraceableTrait;

Expand Down
5 changes: 3 additions & 2 deletions system/Cache/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

use Closure;
use CodeIgniter\Cache\CacheInterface;
use CodeIgniter\Exceptions\BadMethodCallException;
use CodeIgniter\Exceptions\InvalidArgumentException;
use Config\Cache;
use Exception;
use InvalidArgumentException;

/**
* Base class for cache handling
Expand Down Expand Up @@ -108,6 +109,6 @@ public function remember(string $key, int $ttl, Closure $callback)
*/
public function deleteMatching(string $pattern)
{
throw new Exception('The deleteMatching method is not implemented.');
throw new BadMethodCallException('The deleteMatching method is not implemented.');
}
}
3 changes: 2 additions & 1 deletion system/Cache/Handlers/MemcachedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace CodeIgniter\Cache\Handlers;

use CodeIgniter\Exceptions\BadMethodCallException;
use CodeIgniter\Exceptions\CriticalError;
use CodeIgniter\I18n\Time;
use Config\Cache;
Expand Down Expand Up @@ -197,7 +198,7 @@ public function delete(string $key)
*/
public function deleteMatching(string $pattern)
{
throw new Exception('The deleteMatching method is not implemented for Memcached. You must select File, Redis or Predis handlers to use it.');
throw new BadMethodCallException('The deleteMatching method is not implemented for Memcached. You must select File, Redis or Predis handlers to use it.');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions system/Cache/Handlers/WincacheHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace CodeIgniter\Cache\Handlers;

use CodeIgniter\Exceptions\BadMethodCallException;
use CodeIgniter\I18n\Time;
use Config\Cache;
use Exception;

/**
* Cache handler for WinCache from Microsoft & IIS.
Expand Down Expand Up @@ -80,7 +80,7 @@ public function delete(string $key)
*/
public function deleteMatching(string $pattern)
{
throw new Exception('The deleteMatching method is not implemented for Wincache. You must select File, Redis or Predis handlers to use it.');
throw new BadMethodCallException('The deleteMatching method is not implemented for Wincache. You must select File, Redis or Predis handlers to use it.');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions system/Cache/ResponseCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

namespace CodeIgniter\Cache;

use CodeIgniter\Exceptions\RuntimeException;
use CodeIgniter\HTTP\CLIRequest;
use CodeIgniter\HTTP\Header;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Cache as CacheConfig;
use Exception;

/**
* Web Page Caching
Expand Down Expand Up @@ -131,7 +131,7 @@ public function get($request, ResponseInterface $response): ?ResponseInterface
|| ! isset($cachedResponse['output'])
|| ! isset($cachedResponse['headers'])
) {
throw new Exception('Error unserializing page cache');
throw new RuntimeException('Error unserializing page cache');
}

$headers = $cachedResponse['headers'];
Expand Down
2 changes: 1 addition & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use CodeIgniter\Debug\Timer;
use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\FrameworkException;
use CodeIgniter\Exceptions\LogicException;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\Filters\Filters;
use CodeIgniter\HTTP\CLIRequest;
Expand All @@ -41,7 +42,6 @@
use Kint\Renderer\CliRenderer;
use Kint\Renderer\RichRenderer;
use Locale;
use LogicException;
use Throwable;

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Database/ShowTableInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Exceptions\InvalidArgumentException;
use Config\Database;
use InvalidArgumentException;

/**
* Get table data if it exists in the database.
Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Utilities/Optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use CodeIgniter\Autoloader\FileLocatorCached;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\Exceptions\RuntimeException;
use CodeIgniter\Publisher\Publisher;
use RuntimeException;

/**
* Optimize for production.
Expand Down
2 changes: 2 additions & 0 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Debug\Timer;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\Exceptions\RuntimeException;
use CodeIgniter\Files\Exceptions\FileNotFoundException;
use CodeIgniter\HTTP\CLIRequest;
use CodeIgniter\HTTP\Exceptions\HTTPException;
Expand Down
2 changes: 1 addition & 1 deletion system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

namespace CodeIgniter\Config;

use CodeIgniter\Exceptions\RuntimeException;
use Config\Encryption;
use Config\Modules;
use ReflectionClass;
use ReflectionException;
use RuntimeException;

/**
* Class BaseConfig
Expand Down
2 changes: 1 addition & 1 deletion system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use CodeIgniter\Debug\Toolbar;
use CodeIgniter\Email\Email;
use CodeIgniter\Encryption\EncrypterInterface;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\Filters\Filters;
use CodeIgniter\Format\Format;
use CodeIgniter\Honeypot\Honeypot;
Expand Down Expand Up @@ -78,7 +79,6 @@
use Config\Toolbar as ConfigToolbar;
use Config\Validation as ConfigValidation;
use Config\View as ConfigView;
use InvalidArgumentException;

/**
* Services Configuration file.
Expand Down
2 changes: 1 addition & 1 deletion system/Config/DotEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace CodeIgniter\Config;

use InvalidArgumentException;
use CodeIgniter\Exceptions\InvalidArgumentException;

/**
* Environment-specific configuration
Expand Down
2 changes: 1 addition & 1 deletion system/Config/Factories.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace CodeIgniter\Config;

use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\Model;
use InvalidArgumentException;

/**
* Factories for creating instances.
Expand Down
4 changes: 2 additions & 2 deletions system/Cookie/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

use ArrayAccess;
use CodeIgniter\Cookie\Exceptions\CookieException;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\Exceptions\LogicException;
use CodeIgniter\I18n\Time;
use Config\Cookie as CookieConfig;
use DateTimeInterface;
use InvalidArgumentException;
use LogicException;
use ReturnTypeWillChange;

/**
Expand Down
2 changes: 1 addition & 1 deletion system/DataCaster/Cast/BaseCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace CodeIgniter\DataCaster\Cast;

use InvalidArgumentException;
use CodeIgniter\Exceptions\InvalidArgumentException;

abstract class BaseCast implements CastInterface
{
Expand Down
2 changes: 1 addition & 1 deletion system/DataCaster/Cast/DatetimeCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace CodeIgniter\DataCaster\Cast;

use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\I18n\Time;
use InvalidArgumentException;

/**
* Class DatetimeCast
Expand Down
2 changes: 1 addition & 1 deletion system/DataCaster/DataCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use CodeIgniter\DataCaster\Cast\URICast;
use CodeIgniter\Entity\Cast\CastInterface as EntityCastInterface;
use CodeIgniter\Entity\Exceptions\CastException;
use InvalidArgumentException;
use CodeIgniter\Exceptions\InvalidArgumentException;

final class DataCaster
{
Expand Down
2 changes: 1 addition & 1 deletion system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Closure;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Database\Exceptions\DataException;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\Traits\ConditionalTrait;
use Config\Feature;
use InvalidArgumentException;

/**
* Class BaseBuilder
Expand Down
2 changes: 1 addition & 1 deletion system/Database/BasePreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
namespace CodeIgniter\Database;

use ArgumentCountError;
use BadMethodCallException;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\BadMethodCallException;
use ErrorException;

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace CodeIgniter\Database;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Exceptions\InvalidArgumentException;
use Config\Database as DbConfig;
use InvalidArgumentException;

/**
* Class Config
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace CodeIgniter\Database;

use InvalidArgumentException;
use CodeIgniter\Exceptions\InvalidArgumentException;

/**
* Database Connection Factory
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Exceptions/DataException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace CodeIgniter\Database\Exceptions;

use CodeIgniter\Exceptions\DebugTraceableTrait;
use RuntimeException;
use CodeIgniter\Exceptions\RuntimeException;

class DataException extends RuntimeException implements ExceptionInterface
{
Expand Down
4 changes: 2 additions & 2 deletions system/Database/Exceptions/DatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
namespace CodeIgniter\Database\Exceptions;

use CodeIgniter\Exceptions\HasExitCodeInterface;
use Error;
use CodeIgniter\Exceptions\RuntimeException;

class DatabaseException extends Error implements ExceptionInterface, HasExitCodeInterface
class DatabaseException extends RuntimeException implements ExceptionInterface, HasExitCodeInterface
{
public function getExitCode(): int
{
Expand Down
4 changes: 2 additions & 2 deletions system/Database/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace CodeIgniter\Database;

use CodeIgniter\Database\Exceptions\DatabaseException;
use InvalidArgumentException;
use RuntimeException;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\Exceptions\RuntimeException;
use Throwable;

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
use CodeIgniter\CLI\CLI;
use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\ConfigException;
use CodeIgniter\Exceptions\RuntimeException;
use CodeIgniter\I18n\Time;
use Config\Database;
use Config\Migrations as MigrationsConfig;
use Config\Services;
use RuntimeException;
use stdClass;

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MySQLi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Database\Exceptions\DatabaseException;
use LogicException;
use CodeIgniter\Exceptions\LogicException;
use mysqli;
use mysqli_result;
use mysqli_sql_exception;
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MySQLi/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace CodeIgniter\Database\MySQLi;

use BadMethodCallException;
use CodeIgniter\Database\BasePreparedQuery;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Exceptions\BadMethodCallException;
use mysqli;
use mysqli_result;
use mysqli_sql_exception;
Expand Down
Loading
Loading