CmsException
extends ApplicationException
in package
The CMS exception class.
The exception class handles CMS related errors. Allows the masking of other exception types which uses actual source CMS files -- instead of cached files -- for their error content.
Tags
Table of Contents
- $hint : string
- $className : string
- $compoundObject : CmsCompoundObject
- $errorCodes : array<string|int, mixed>
- $errorType : string
- $fileContent : array<string|int, mixed>
- $highlight : stdObject
- $mask : Exception
- __construct() : mixed
- Creates the CMS exception object.
- applyMask() : void
- Masks this exception with the details of the supplied. The error code for this exception object will determine how the supplied exception is used.
- getCallStack() : array<string|int, mixed>
- Returns the call stack as an array of values containing a stack information object.
- getClassName() : string
- Returns the class name of the called Exception.
- getErrorType() : string
- Returns the error type derived from the error code used.
- getHighlight() : array<string|int, mixed>
- Generates information used for highlighting the area of code in context of the exception line number.
- getHighlightLines() : array<string|int, mixed>
- Returns an array of line numbers used for highlighting the problem area of code.
- getTrueException() : Exception
- If this exception is acting as a mask, return the face exception. Otherwise return this exception as the true one.
- mask() : void
- Masks an exception with the called class. This should catch fatal and php errors.
- processCompoundObject() : bool
- Checks some conditions to confirm error has actually occurred due to the CMS template code, not some external code. If the error has occurred in external code, the function will return false. Otherwise return true and modify the exception by overriding it's content, line and message values to be accurate against a CMS object properties.
- setMask() : void
- If this exception acts as a mask, sets the face for the foreign exception.
- unmask() : void
- Removes the active mask from the called class.
- filterCallStack() : array<string|int, mixed>
- Removes the final steps of a call stack, which add no value for the user.
- formatStackArguments() : string
- Prepares a function or method argument list for display in HTML or text format
- processIni() : bool
- Override properties of an exception specific to the INI section of a CMS object.
- processPhp() : bool
- Override properties of an exception specific to the PHP section of a CMS object.
- processTwig() : bool
- Override properties of an exception specific to the Twig section of a CMS object.
Properties
$hint
public
string
$hint
Hint Message to help the user with troubleshooting the error (optional).
$className
protected
string
$className
Class name of the called Exception.
$compoundObject
protected
CmsCompoundObject
$compoundObject
A reference to a CMS object used for masking errors.
$errorCodes
protected
static array<string|int, mixed>
$errorCodes
= [100 => 'General', 200 => 'INI Settings', 300 => 'PHP Content', 400 => 'Twig Template']
Collection of error codes for each error distinction.
$errorType
protected
string
$errorType
Error type derived from the error code. Will be 'Undefined' if no code is used.
$fileContent
protected
array<string|int, mixed>
$fileContent
= []
File content relating to the exception, each value of the array is a file line number.
$highlight
protected
stdObject
$highlight
Cached code information for highlighting code.
$mask
protected
Exception
$mask
If this exception is acting as a mask, this property stores the face exception.
Methods
__construct()
Creates the CMS exception object.
public
__construct([mixed $message = null ][, int $code = 100 ][, Exception $previous = null ]) : mixed
Parameters
- $message : mixed = null
-
The message to display as a string, or a CmsCompoundObject that is used for using this exception as a mask for another exception type.
- $code : int = 100
-
Error code to specify the exception type: Error 100: A general exception. Error 200: Mask the exception as INI content. Error 300: Mask the exception as PHP content. Error 400: Mask the exception as Twig content.
- $previous : Exception = null
-
Previous exception.
Return values
mixed —applyMask()
Masks this exception with the details of the supplied. The error code for this exception object will determine how the supplied exception is used.
public
applyMask(Exception $exception) : void
Error 100: A general exception. Inherits \System\Classes\ExceptionBase::applyMask() Error 200: Mask the exception as INI content. Error 300: Mask the exception as PHP content. Error 400: Mask the exception as Twig content.
Parameters
- $exception : Exception
-
The exception to modify.
Return values
void —getCallStack()
Returns the call stack as an array of values containing a stack information object.
public
getCallStack() : array<string|int, mixed>
Return values
array<string|int, mixed> —with stack information, each value will be an object with these values: id - The stack ID number. code - The class and function name being called. args - The arguments passed to the code function above. file - Reference to the file containing the called code. line - Reference to the line number of the file.
getClassName()
Returns the class name of the called Exception.
public
getClassName() : string
Return values
string —getErrorType()
Returns the error type derived from the error code used.
public
getErrorType() : string
Return values
string —getHighlight()
Generates information used for highlighting the area of code in context of the exception line number.
public
getHighlight() : array<string|int, mixed>
The highlighted block of code will be six (6) lines before and after the problem line number.
Return values
array<string|int, mixed> —Highlight information as an array, the following keys are supplied: startLine - The starting line number, 6 lines before the error line. endLine - The ending line number, 6 lines after the error line. errorLine - The focused error line number. lines - An array of all the lines to be highlighted, each value is a line of code.
getHighlightLines()
Returns an array of line numbers used for highlighting the problem area of code.
public
getHighlightLines() : array<string|int, mixed>
This will be six (6) lines before and after the error line number.
Return values
array<string|int, mixed> —Array of code lines.
getTrueException()
If this exception is acting as a mask, return the face exception. Otherwise return this exception as the true one.
public
getTrueException() : Exception
Return values
Exception —The underlying exception, or this exception if no mask is applied.
mask()
Masks an exception with the called class. This should catch fatal and php errors.
public
static mask([string $message = null ], int $code) : void
It should always be followed by the unmask() method to remove the mask.
Parameters
- $message : string = null
-
Error message.
- $code : int
-
Error code.
Return values
void —processCompoundObject()
Checks some conditions to confirm error has actually occurred due to the CMS template code, not some external code. If the error has occurred in external code, the function will return false. Otherwise return true and modify the exception by overriding it's content, line and message values to be accurate against a CMS object properties.
public
processCompoundObject(Exception $exception) : bool
Parameters
- $exception : Exception
-
The exception to modify.
Return values
bool —setMask()
If this exception acts as a mask, sets the face for the foreign exception.
public
setMask(Exception $exception) : void
Parameters
- $exception : Exception
-
Face for the mask, the underlying exception.
Return values
void —unmask()
Removes the active mask from the called class.
public
static unmask() : void
Return values
void —filterCallStack()
Removes the final steps of a call stack, which add no value for the user.
protected
filterCallStack(array<string|int, mixed> $traceInfo) : array<string|int, mixed>
The following exceptions and any trace information afterwards will be filtered:
- Illuminate\Foundation\Bootstrap\HandleExceptions
Parameters
- $traceInfo : array<string|int, mixed>
-
The trace information from getTrace() or debug_backtrace().
Return values
array<string|int, mixed> —The filtered array containing the trace information.
formatStackArguments()
Prepares a function or method argument list for display in HTML or text format
protected
formatStackArguments(array<string|int, mixed> $arguments) : string
Parameters
- $arguments : array<string|int, mixed>
-
A list of the function or method arguments
Return values
string —processIni()
Override properties of an exception specific to the INI section of a CMS object.
protected
processIni(Exception $exception) : bool
Parameters
- $exception : Exception
-
The exception to modify.
Return values
bool —processPhp()
Override properties of an exception specific to the PHP section of a CMS object.
protected
processPhp(Exception $exception) : bool
Parameters
- $exception : Exception
-
The exception to modify.
Return values
bool —processTwig()
Override properties of an exception specific to the Twig section of a CMS object.
protected
processTwig(Exception $exception) : bool
Parameters
- $exception : Exception
-
The exception to modify.