First Local Commit - After Clean up.

Signed-off-by: Rick Hays <rhays@haysgang.com>
This commit is contained in:
2019-12-02 14:54:38 -06:00
commit 10412ab7f6
486 changed files with 123242 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?php namespace CodeIgniter\Exceptions;
/**
* Error: Action must be taken immediately (system/db down, etc)
*/
class AlertError extends \Error
{
}

View 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'));
}
}
}

View 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'));
}
}

View File

@@ -0,0 +1,10 @@
<?php namespace CodeIgniter\Exceptions;
/**
* Error: Critical conditions, like component unavailble, etc.
*/
class CriticalError extends \Error
{
}

View 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]));
}
}

View File

@@ -0,0 +1,10 @@
<?php namespace CodeIgniter\Exceptions;
/**
* Error: system is unusable
*/
class EmergencyError extends \Error
{
}

View 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
{
}

View 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]));
}
}

View 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]));
}
}

View 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]));
}
}