class ErrorManager extends Singleton

The main error handler/manager

This class handles uncaught exceptions, logging them and converting to a client Output object. Application code can use LogException() when an exception is caught but still needs to be logged.

Properties

static private $instances from  Singleton
private $API
private $interface
private $filelogok

if false, the file-based log encountered an error on the last entry

private $dblogok

if false, the DB-based log encountered an error on the last entry

private $debuglog

Methods

static Singleton
GetInstance()

Get the instance of the singleton

__construct(IOInterface $interface)

Registers PHP error and exception handlers

bool
GetDebugState(int $minlevel)

Returns true if the configured debug state is >= the requested level

HandleClientException(ClientException $e)

Handles a client exception, rolling back the DB, displaying debug data and returning an Output

HandleThrowable(Throwable $e)

Handles a non-client exception, rolling back the DB, logging debug data and returning an Output

__destruct()

No description

SetAPI(Main $api)

No description

array|null
LogException(Throwable $e, bool $mainlog = true)

Log an exception to file (json) and database

LogDebug($data)

Adds an entry to the custom debug log, saved with exceptions

array|null
GetDebugLog()

Returns the debug log if allowed by the debug state, else null

LogBreakpoint()

Creates an exception and logs it to the main error log (to get a backtrace)

Details

in Singleton at line 21
static Singleton GetInstance()

Get the instance of the singleton

Return Value

Singleton

Exceptions

MissingSingletonException

if not yet constructed

at line 58
__construct(IOInterface $interface)

Registers PHP error and exception handlers

Parameters

IOInterface $interface

at line 28
private bool GetDebugState(int $minlevel)

Returns true if the configured debug state is >= the requested level

Parameters

int $minlevel

Return Value

bool

at line 36
private Output HandleClientException(ClientException $e)

Handles a client exception, rolling back the DB, displaying debug data and returning an Output

Parameters

ClientException $e

Return Value

Output

at line 47
private Output HandleThrowable(Throwable $e)

Handles a non-client exception, rolling back the DB, logging debug data and returning an Output

Parameters

Throwable $e

Return Value

Output

at line 83
__destruct()

No description

at line 85
ErrorManager SetAPI(Main $api)

No description

Parameters

Main $api

Return Value

ErrorManager

at line 101
array|null LogException(Throwable $e, bool $mainlog = true)

Log an exception to file (json) and database

A new database connection is used for the log entry

Parameters

Throwable $e

the exception to log

bool $mainlog

if true, display this in the API's message log

Return Value

array|null

array of debug data or null if not logged

at line 147
ErrorManager LogDebug($data)

Adds an entry to the custom debug log, saved with exceptions

Parameters

$data

Return Value

ErrorManager

at line 150
array|null GetDebugLog()

Returns the debug log if allowed by the debug state, else null

Return Value

array|null

at line 153
ErrorManager LogBreakpoint()

Creates an exception and logs it to the main error log (to get a backtrace)

Return Value

ErrorManager