CmsException

The CMS exception class.

 class Cms\Classes\CmsException
extends Winter\Storm\Exception\ApplicationException

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.

Extends

Class Description
ApplicationException

This class represents an application exception.

Properties

protected $compoundObject : Cms\Classes\CmsCompoundObject

A reference to a CMS object used for masking errors.

protected static $errorCodes : array

Collection of error codes for each error distinction.

inherited public $hint : string

Inherited from ExceptionBase

Hint Message to help the user with troubleshooting the error (optional).

inherited protected $className : string

Inherited from ExceptionBase

Class name of the called Exception.

inherited protected $errorType : string

Inherited from ExceptionBase

Error type derived from the error code. Will be 'Undefined' if no code is used.

inherited protected $fileContent : array

Inherited from ExceptionBase

File content relating to the exception, each value of the array is a file line number.

inherited protected $highlight : object

Inherited from ExceptionBase

Cached code information for highlighting code.

inherited protected $mask : Throwable

Inherited from ExceptionBase

If this exception is acting as a mask, this property stores the face exception.

Methods

public __construct (mixed $message = null, integer $code = 100, Throwable $previous = null)

Creates the CMS exception object.

Parameters
Property Description
$message
mixed

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
integer

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
Throwable

Previous exception.

Returns
mixed

public applyMask (Throwable $exception) : 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.

Error 100: A general exception. Inherits \Winter\Storm\Exception\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
Property Description
$exception
Throwable

The exception to modify.

Returns
void

public processCompoundObject (Throwable $exception) : 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.

Parameters
Property Description
$exception
Throwable

The exception to modify.

Returns
bool

protected processIni (Throwable $exception) : bool

Override properties of an exception specific to the INI section of a CMS object.

Parameters
Property Description
$exception
Throwable

The exception to modify.

Returns
bool

protected processPhp (Throwable $exception) : bool

Override properties of an exception specific to the PHP section of a CMS object.

Parameters
Property Description
$exception
Throwable

The exception to modify.

Returns
bool

protected processTwig (Throwable $exception) : bool

Override properties of an exception specific to the Twig section of a CMS object.

Parameters
Property Description
$exception
Throwable

The exception to modify.

Returns
bool

inherited public getCallStack () : array

Inherited from ExceptionBase

Returns the call stack as an array of values containing a stack information object.

Returns
array

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.

inherited public getClassName () : string

Inherited from ExceptionBase

Returns the class name of the called Exception.

Returns
string

inherited public getErrorType () : string

Inherited from ExceptionBase

Returns the error type derived from the error code used.

Returns
string

inherited public getHighlight () : object

Inherited from ExceptionBase

Generates information used for highlighting the area of code in context of the exception line number.

The highlighted block of code will be six (6) lines before and after the problem line number.

Returns
object

Highlight information as an object, 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.

inherited public getHighlightLines () : array

Inherited from ExceptionBase

Returns an array of line numbers used for highlighting the problem area of code.

This will be six (6) lines before and after the error line number.

Returns
array

Array of code lines.

inherited public getTrueException () : Throwable

Inherited from ExceptionBase

If this exception is acting as a mask, return the face exception. Otherwise return this exception as the true one.

Returns
Throwable

The underlying exception, or this exception if no mask is applied.

inherited public static mask (string $message = null, integer $code) : void

Inherited from ExceptionBase

Masks an exception with the called class. This should catch fatal and php errors.

It should always be followed by the unmask() method to remove the mask.

Parameters
Property Description
$message
string

Error message.

$code
integer

Error code.

Returns
void

inherited public setMask (Throwable $exception) : void

Inherited from ExceptionBase

If this exception acts as a mask, sets the face for the foreign exception.

Parameters
Property Description
$exception
Throwable

Face for the mask, the underlying exception.

Returns
void

inherited public static unmask () : void

Inherited from ExceptionBase

Removes the active mask from the called class.

Returns
void

inherited protected filterCallStack (array $traceInfo) : array

Inherited from ExceptionBase

Removes the final steps of a call stack, which add no value for the user.

The following exceptions and any trace information afterwards will be filtered:

  • Illuminate\Foundation\Bootstrap\HandleExceptions
Parameters
Property Description
$traceInfo
array

The trace information from getTrace() or debug_backtrace().

Returns
array

The filtered array containing the trace information.

inherited protected formatStackArguments (array $arguments) : string

Inherited from ExceptionBase

Prepares a function or method argument list for display in HTML or text format

Parameters
Property Description
$arguments
array

A list of the function or method arguments

Returns
string
Copyright © 2024 Winter CMS