Documentation

CRM_Queue_ErrorPolicy
in package

To ensure that PHP errors or unhandled exceptions are reported in JSON format, wrap this around your code. For example:

$errorContainer = new CRM_Queue_ErrorPolicy();
$errorContainer->call(function() {
   ...include some files, do some work, etc...
});

Note: Most of the code in this class is pretty generic vis-a-vis error handling -- except for 'reportError', whose message format is only appropriate for use with the CRM_Queue_Page_AJAX. Some kind of cleanup will be necessary to get reuse from the other parts of this class.

Table of Contents

Properties

$active  : bool
$backup  : array<string|int, mixed>
$level  : int

Methods

__construct()  : mixed
call()  : mixed
Execute the callable. Activate and deactivate the error policy automatically.
onError()  : bool
Receive (semi) recoverable error notices.
onShutdown()  : mixed
Receive non-recoverable error notices
activate()  : mixed
Enable the error policy.
deactivate()  : mixed
Disable the error policy.
reportError()  : mixed
Print a fatal error.
reportException()  : mixed
Print an unhandled exception.

Properties

Methods

__construct()

public __construct([null|int $level = NULL ]) : mixed
Parameters
$level : null|int = NULL

PHP error level to capture (e.g. E_PARSE|E_USER_ERROR).

call()

Execute the callable. Activate and deactivate the error policy automatically.

public call(callable|array<string|int, mixed>|string $callable) : mixed
Parameters
$callable : callable|array<string|int, mixed>|string

A callback function.

onError()

Receive (semi) recoverable error notices.

public onError(string $errno, string $errstr, string $errfile, int $errline) : bool
Parameters
$errno : string
$errstr : string
$errfile : string
$errline : int
Tags
see
set_error_handler
throws
Exception
Return values
bool

onShutdown()

Receive non-recoverable error notices

public onShutdown() : mixed
Tags
see
register_shutdown_function
see
error_get_last

activate()

Enable the error policy.

protected activate() : mixed

deactivate()

Disable the error policy.

protected deactivate() : mixed

reportError()

Print a fatal error.

protected reportError(array<string|int, mixed> $error) : mixed
Parameters
$error : array<string|int, mixed>

The PHP error (with "type", "message", etc).

reportException()

Print an unhandled exception.

protected reportException(Exception $e) : mixed
Parameters
$e : Exception

The unhandled exception.


        
On this page

Search results