\Sitebill_Error

Summary

Methods
Properties
Constants
__construct()
get_error_codes()
get_error_code()
get_error_messages()
get_error_message()
get_error_data()
add()
add_data()
$errors
$error_data
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$errors

$errors : array

Stores the list of errors.

Type

array

$error_data

$error_data : array

Stores the list of data for error codes.

Type

array

Methods

__construct()

__construct(string|integer  $code = '', string  $message = '', mixed  $data = '') : \Sitebill_Error

Constructor - Sets up error message.

If code parameter is empty then nothing will be done. It is possible to add multiple messages to the same code, but with other methods in the class.

All parameters are optional, but if the code parameter is set, then the data parameter is optional.

Parameters

string|integer $code

Error code

string $message

Error message

mixed $data

Optional. Error data.

Returns

\Sitebill_Error

get_error_codes()

get_error_codes() : array

Retrieve all error codes.

Returns

array —

List of error codes, if available.

get_error_code()

get_error_code() : string|integer

Retrieve first error code available.

Returns

string|integer —

Empty string, if no error codes.

get_error_messages()

get_error_messages(string|integer  $code = '') : array

Retrieve all error messages or error messages matching code.

Parameters

string|integer $code

Optional. Retrieve messages matching code, if exists.

Returns

array —

Error strings on success, or empty array on failure (if using code parameter).

get_error_message()

get_error_message(string|integer  $code = '') : string

Get single error message.

This will get the first message available for the code. If no code is given then the first code available will be used.

Parameters

string|integer $code

Optional. Error code to retrieve message.

Returns

string

get_error_data()

get_error_data(string|integer  $code = '') : mixed

Retrieve error data for error code.

Parameters

string|integer $code

Optional. Error code.

Returns

mixed —

Null, if no errors.

add()

add(string|integer  $code, string  $message, mixed  $data = '') 

Append more error messages to list of error messages.

Parameters

string|integer $code

Error code.

string $message

Error message.

mixed $data

Optional. Error data.

add_data()

add_data(mixed  $data, string|integer  $code = '') 

Add data for error code.

The error code can only contain one error data.

Parameters

mixed $data

Error data.

string|integer $code

Error code.