DBQueryException
extends CRM_Core_Exception
in package
Error when the syntax of a DB query is incorrect.
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.
- getDBErrorMessage() : string
- Get the DB error code converted to a test code.
- getDebugInfo() : string
- Get the attempted sql.
- 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.
- getSQL() : string
- Get the attempted sql.
- getSQLErrorCode() : int
- Get the mysql error code.
- getUserInfo() : string
- Get the PEAR data intended to be use useful to the user.
- getUserMessage() : string
- Get a message suitable to be presented to the user.
- getDBError() : DB_Error
- getPEARErrorCode() : int
- getErrorCodeSpecificMessage() : string
- Get additional user-safe error message information.
- isErrorMessageUserSafe() : bool
- Is the error message safe to show to users.
Constants
NOT_IMPLEMENTED
public
mixed
NOT_IMPLEMENTED
= 'not-found'
UNAUTHORIZED
public
mixed
UNAUTHORIZED
= 'unauthorized'
Properties
$errorData
private
mixed
$errorData
= []
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
stringgetDBErrorMessage()
Get the DB error code converted to a test code.
public
getDBErrorMessage() : string
Return values
stringgetDebugInfo()
Get the attempted sql.
public
getDebugInfo() : string
Return values
stringgetErrorCode()
Get error code.
public
getErrorCode() : int|string
Return values
int|stringgetErrorCodes()
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>getSQL()
Get the attempted sql.
public
getSQL() : string
Return values
stringgetSQLErrorCode()
Get the mysql error code.
public
getSQLErrorCode() : int
Tags
Return values
intgetUserInfo()
Get the PEAR data intended to be use useful to the user.
public
getUserInfo() : string
Return values
stringgetUserMessage()
Get a message suitable to be presented to the user.
public
getUserMessage() : string
Return values
stringgetDBError()
protected
getDBError() : DB_Error
Return values
DB_ErrorgetPEARErrorCode()
protected
getPEARErrorCode() : int
Return values
intgetErrorCodeSpecificMessage()
Get additional user-safe error message information.
private
getErrorCodeSpecificMessage() : string
Return values
stringisErrorMessageUserSafe()
Is the error message safe to show to users.
private
isErrorMessageUserSafe() : bool
Probably most of them are but error 1146 leaks the database name - eg. 'table dmaster.civicrm_contact does not exist'.
However, for missing fields and syntax errors the error message gives useful clues we should pass on. We can add to this / tweak over time - if we care to.