First Local Commit - After Clean up.
Signed-off-by: Rick Hays <rhays@haysgang.com>
This commit is contained in:
10
system/Exceptions/AlertError.php
Normal file
10
system/Exceptions/AlertError.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Error: Action must be taken immediately (system/db down, etc)
|
||||
*/
|
||||
|
||||
class AlertError extends \Error
|
||||
{
|
||||
|
||||
}
|
||||
41
system/Exceptions/CastException.php
Normal file
41
system/Exceptions/CastException.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Cast Exceptions.
|
||||
*/
|
||||
|
||||
class CastException extends CriticalError
|
||||
{
|
||||
|
||||
/**
|
||||
* Error code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 3;
|
||||
|
||||
public static function forInvalidJsonFormatException(int $error)
|
||||
{
|
||||
switch($error)
|
||||
{
|
||||
case JSON_ERROR_DEPTH:
|
||||
throw new static(lang('Cast.jsonErrorDepth'));
|
||||
break;
|
||||
case JSON_ERROR_STATE_MISMATCH:
|
||||
throw new static(lang('Cast.jsonErrorStateMismatch'));
|
||||
break;
|
||||
case JSON_ERROR_CTRL_CHAR:
|
||||
throw new static(lang('Cast.jsonErrorCtrlChar'));
|
||||
break;
|
||||
case JSON_ERROR_SYNTAX:
|
||||
throw new static(lang('Cast.jsonErrorSyntax'));
|
||||
break;
|
||||
case JSON_ERROR_UTF8:
|
||||
throw new static(lang('Cast.jsonErrorUtf8'));
|
||||
break;
|
||||
default:
|
||||
throw new static(lang('Cast.jsonErrorUnknown'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
21
system/Exceptions/ConfigException.php
Normal file
21
system/Exceptions/ConfigException.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Exception for automatic logging.
|
||||
*/
|
||||
|
||||
class ConfigException extends CriticalError
|
||||
{
|
||||
|
||||
/**
|
||||
* Error code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 3;
|
||||
|
||||
public static function forDisabledMigrations()
|
||||
{
|
||||
throw new static(lang('Migrations.disabled'));
|
||||
}
|
||||
}
|
||||
10
system/Exceptions/CriticalError.php
Normal file
10
system/Exceptions/CriticalError.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Error: Critical conditions, like component unavailble, etc.
|
||||
*/
|
||||
|
||||
class CriticalError extends \Error
|
||||
{
|
||||
|
||||
}
|
||||
36
system/Exceptions/DownloadException.php
Normal file
36
system/Exceptions/DownloadException.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Class DownloadException
|
||||
*
|
||||
* @package CodeIgniter\Exceptions
|
||||
*/
|
||||
|
||||
class DownloadException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
|
||||
public static function forCannotSetFilePath(string $path)
|
||||
{
|
||||
return new static(lang('HTTP.cannotSetFilepath', [$path]));
|
||||
}
|
||||
|
||||
public static function forCannotSetBinary()
|
||||
{
|
||||
return new static(lang('HTTP.cannotSetBinary'));
|
||||
}
|
||||
|
||||
public static function forNotFoundDownloadSource()
|
||||
{
|
||||
return new static(lang('HTTP.notFoundDownloadSource'));
|
||||
}
|
||||
|
||||
public static function forCannotSetCache()
|
||||
{
|
||||
return new static(lang('HTTP.cannotSetCache'));
|
||||
}
|
||||
|
||||
public static function forCannotSetStatusCode(int $code, string $reason)
|
||||
{
|
||||
return new static(lang('HTTP.cannotSetStatusCode', [$code, $reason]));
|
||||
}
|
||||
}
|
||||
10
system/Exceptions/EmergencyError.php
Normal file
10
system/Exceptions/EmergencyError.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Error: system is unusable
|
||||
*/
|
||||
|
||||
class EmergencyError extends \Error
|
||||
{
|
||||
|
||||
}
|
||||
12
system/Exceptions/ExceptionInterface.php
Normal file
12
system/Exceptions/ExceptionInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Provides a domain-level interface for broad capture
|
||||
* of all framework-related exceptions.
|
||||
*
|
||||
* catch (\CodeIgniter\Exceptions\ExceptionInterface) { ... }
|
||||
*/
|
||||
|
||||
interface ExceptionInterface
|
||||
{
|
||||
}
|
||||
35
system/Exceptions/FrameworkException.php
Normal file
35
system/Exceptions/FrameworkException.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FrameworkException
|
||||
*
|
||||
* A collection of exceptions thrown by the framework
|
||||
* that can only be determined at run time.
|
||||
*
|
||||
* @package CodeIgniter\Exceptions
|
||||
*/
|
||||
|
||||
class FrameworkException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
|
||||
public static function forInvalidFile(string $path)
|
||||
{
|
||||
return new static(lang('Core.invalidFile', [$path]));
|
||||
}
|
||||
|
||||
public static function forCopyError(string $path)
|
||||
{
|
||||
return new static(lang('Core.copyError', [$path]));
|
||||
}
|
||||
|
||||
public static function forMissingExtension(string $extension)
|
||||
{
|
||||
return new static(lang('Core.missingExtension', [$extension]));
|
||||
}
|
||||
|
||||
public static function forNoHandlers(string $class)
|
||||
{
|
||||
return new static(lang('Core.noHandlers', [$class]));
|
||||
}
|
||||
|
||||
}
|
||||
18
system/Exceptions/ModelException.php
Normal file
18
system/Exceptions/ModelException.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
/**
|
||||
* Model Exceptions.
|
||||
*/
|
||||
|
||||
class ModelException extends FrameworkException
|
||||
{
|
||||
public static function forNoPrimaryKey(string $modelName)
|
||||
{
|
||||
return new static(lang('Database.noPrimaryKey', [$modelName]));
|
||||
}
|
||||
|
||||
public static function forNoDateFormat(string $modelName)
|
||||
{
|
||||
return new static(lang('Database.noDateFormat', [$modelName]));
|
||||
}
|
||||
}
|
||||
31
system/Exceptions/PageNotFoundException.php
Normal file
31
system/Exceptions/PageNotFoundException.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php namespace CodeIgniter\Exceptions;
|
||||
|
||||
class PageNotFoundException extends \OutOfBoundsException implements ExceptionInterface
|
||||
{
|
||||
/**
|
||||
* Error code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 404;
|
||||
|
||||
public static function forPageNotFound(string $message = null)
|
||||
{
|
||||
return new static($message ?? lang('HTTP.pageNotFound'));
|
||||
}
|
||||
|
||||
public static function forEmptyController()
|
||||
{
|
||||
return new static(lang('HTTP.emptyController'));
|
||||
}
|
||||
|
||||
public static function forControllerNotFound(string $controller, string $method)
|
||||
{
|
||||
return new static(lang('HTTP.controllerNotFound', [$controller, $method]));
|
||||
}
|
||||
|
||||
public static function forMethodNotFound(string $method)
|
||||
{
|
||||
return new static(lang('HTTP.methodNotFound', [$method]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user