ExceptionBase

The base exception class.

 class Winter\Storm\Exception\ExceptionBase
extends Exception

This class represents a base interface and set of properties for system and application exceptions.

Extends

Class Description
Exception

Properties

public $hint : string

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

protected $className : string

Class name of the called Exception.

protected $errorType : string

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

protected $fileContent : array

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

protected $highlight : object

Cached code information for highlighting code.

protected $mask : Throwable

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

Methods

public __construct (string $message = "", integer $code, Throwable $previous = null)

CMS base exception class constructor. Inherits the native PHP Exception.

All CMS related classes should inherit this class, it creates a set of unified properties and an interface for displaying the CMS exception page.

Parameters
Property Description
$message
string

Error message.

$code
integer

Error code.

$previous
Throwable

Previous exception.

Returns
mixed

public applyMask (Throwable $exception) : void

This method is used when applying the mask exception to the face exception.

It can be used as an override for child classes who may use different masking logic.

Parameters
Property Description
$exception
Throwable

Face exception being masked.

Returns
void

public getCallStack () : array

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.

public getClassName () : string

Returns the class name of the called Exception.

Returns
string

public getErrorType () : string

Returns the error type derived from the error code used.

Returns
string

public getHighlight () : object

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.

public getHighlightLines () : array

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.

public getTrueException () : Throwable

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.

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

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

public setMask (Throwable $exception) : void

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

public static unmask () : void

Removes the active mask from the called class.

Returns
void

protected filterCallStack (array $traceInfo) : array

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.

protected formatStackArguments (array $arguments) : string

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

Extended by

Class Description
AjaxException

This class represents an AJAX exception.

ApplicationException

This class represents an application exception.

SystemException

This class represents a critical system exception.

Copyright © 2024 Winter CMS