Documentation

CRM_Core_Exception extends PEAR_Exception
in package

Base class for exceptions generated by CiviCRM.

This Exception returns more information than the default one. We are using it from the form layer to allow redirects to occur without having redirects in the BAO

Table of Contents

Constants

NOT_IMPLEMENTED  = 'not-found'
UNAUTHORIZED  = 'unauthorized'

Properties

$errorData  : mixed

Methods

__construct()  : mixed
Class constructor.
__toString()  : string
Custom string representation of object.
getErrorCode()  : int|string
Get error code.
getErrorCodes()  : array<string|int, mixed>
Get error codes.
getErrorData()  : array<string|int, mixed>
Return specific error information.
getExtraParams()  : array<string|int, mixed>
Get extra parameters.
getUserMessage()  : string
Get a message suitable to be presented to the user.

Constants

NOT_IMPLEMENTED

public mixed NOT_IMPLEMENTED = 'not-found'

UNAUTHORIZED

public mixed UNAUTHORIZED = 'unauthorized'

Properties

Methods

__construct()

Class constructor.

public __construct(string $message[, int|string $error_code = 0 ][, array<string|int, mixed> $errorData = [] ][, Throwable|null $previous = NULL ]) : mixed
Parameters
$message : string

The human friendly error message.

$error_code : int|string = 0

A computer friendly error code. By convention, no space (but underscore allowed) (ex: mandatory_missing, duplicate, invalid_format).

$errorData : array<string|int, mixed> = []

Extra params to return. eg an extra array of ids. It is not mandatory, but can help the computer using the api. Keep in mind the api consumer isn't to be trusted. eg. the database password is NOT a good extra data.

$previous : Throwable|null = NULL

A previous exception which caused this new exception.

__toString()

Custom string representation of object.

public __toString() : string
Return values
string

getErrorCode()

Get error code.

public getErrorCode() : int|string
Return values
int|string

getErrorCodes()

Get error codes.

public getErrorCodes() : array<string|int, mixed>

DIVERGENCE: API_Exception defined a discoverable list of error-codes. CRM_Core_Exception and CiviCRM_API3_Exception did not.

Return values
array<string|int, mixed>

getErrorData()

Return specific error information.

public getErrorData() : array<string|int, mixed>

(Can be used for more detailed error messages or translation.)

This method may be overridden in child exception classes in order to add functionality not present in PEAR_Exception and is a placeholder to define API

The returned array must be an associative array of parameter => value like so:

array('name' => $name, 'context' => array(...))
Return values
array<string|int, mixed>

getExtraParams()

Get extra parameters.

public getExtraParams() : array<string|int, mixed>

Remove in v6.0. Compatibility with older API_Exception/CiviCRM_API3_Exception contracts.

Return values
array<string|int, mixed>

getUserMessage()

Get a message suitable to be presented to the user.

public getUserMessage() : string
Return values
string

        
On this page

Search results