abstract class vB_Exception extends Exception

vB Exception Base class for all exceptions.

The standard error message fetched with getMessage() should not be given to the end user and should be used only for development. For this reason, they should not need to be localised.

Exceptions that will use a user visible message should implement their own method to do so.

Traits

Properties

protected bool $critical Whether the exception is considered as critical by default.
protected string $option_mail The vb option that decides whether to mail the admin about the exception.
protected sring $option_log The vb option that decides whether to log the exception.
protected string $config_debug The vb option that decides whether to debug the exception.
protected bool $logged Whether the exception has already been logged.
protected bool $mailed Whether the exception has already been mailed.

Methods

__sleep()

No description

__wakeup()

No description

static string
getFullTrace(Exception $e)

Returns the stack trace for an exception

__construct(string $message, int $code = false, string $file = false, int $line = false)

Constructor.

logError()

Logs details of the error.

mailError()

Sends details of the error to a configured email address.

string
toString(bool $verbose = false)

Creates a string representation of the error.

__toString()

Magic method.

bool
isCritical()

Checks if an exception is considered critical.

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 102
static string getFullTrace(Exception $e)

Returns the stack trace for an exception

The exception class provides a getTrace and getTraceAsString function, but maddeningly, these do not include the line on which the exception was thrown. This function adds that information the to the string trace and returns it

Declared as as static function so we can use this with other people's exceptions
as well as our own.

Parameters

Exception $e

Return Value

string

at line 127
__construct(string $message, int $code = false, string $file = false, int $line = false)

Constructor.

Checks whether the error should be logged, mailed and/or debugged.

Parameters

string $message
  • A description of the error
int $code
  • The PHP code of the error
string $file
  • The file the exception was thrown from
int $line
  • The line the exception was thrown from

at line 192
logError()

Logs details of the error.

at line 208
mailError()

Sends details of the error to a configured email address.

at line 230
string toString(bool $verbose = false)

Creates a string representation of the error.

This is useful when logging or mailing the error and displays full details of the error and where it occurred, including a full stack trace.

Parameters

bool $verbose
  • Whether to display full details

Return Value

string

at line 255
__toString()

Magic method.

Seperated from toString function because __toString cannot take parameters in 5.3

at line 267
bool isCritical()

Checks if an exception is considered critical.

Return Value

bool