-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1283 from bcit-ci/entities
Entities
- Loading branch information
Showing
4 changed files
with
123 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php namespace CodeIgniter\Exceptions; | ||
|
||
/** | ||
* Cast Exceptions. | ||
*/ | ||
class CastException extends CriticalError | ||
{ | ||
|
||
/** | ||
* Error code | ||
* @var int | ||
*/ | ||
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')); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* Cast language strings. | ||
* | ||
* @package CodeIgniter | ||
* @author CodeIgniter Dev Team | ||
* @copyright 2014-2018 British Columbia Institute of Technology (https://bcit.ca/) | ||
* @license https://opensource.org/licenses/MIT MIT License | ||
* @link https://codeigniter.com | ||
* @since Version 3.0.0 | ||
* @filesource | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
|
||
return [ | ||
'jsonErrorDepth' => 'Maximum stack depth exceeded', | ||
'jsonErrorStateMismatch' => 'Underflow or the modes mismatch', | ||
'jsonErrorCtrlChar' => 'Unexpected control character found', | ||
'jsonErrorSyntax' => 'Syntax error, malformed JSON', | ||
'jsonErrorUtf8' => 'Malformed UTF-8 characters, possibly incorrectly encoded', | ||
'jsonErrorUnknown' => 'Unknown error' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters