Add global configuration settings for error handling.
Make passing of error messages more consistent.
*/
namespace n_koopa;
-
/**
* A collection of global settings for use by the entire project.
*
* This is intended to be modified by the developers or site developers of a project.
*
- * Warning: Any variables defined here (due to being global) must be considered not thread-safe.
+ * Warning: Any variables defined here (due to being global) must be considered non-thread-safe.
* Be sure to handle carefully when using threads.
* It is recommended to process and pre-set as much of this as possible before starting threads.
*/
const ERROR_BACKTRACE_ARGUMENTS = FALSE;
// provide a language to fallback to if none is set.
- const LANGUAGE_CLASS_DEFAULT = 'c_base_languages_us_only';
+ const LANGUAGE_CLASS_DEFAULT = '\n_koopa\c_base_languages_us_only';
+
+ // provide an error message handler to fallback to if none is set.
+ const ERROR_MESSAGE_HANDLER_CLASS_DEFAULT = '\n_koopa\c_base_error_messages_english';
+
+ // provide the include path for the default/fallback error message handler class.
+ const ERROR_MESSAGE_HANDLER_PATH_DEFAULT = 'common/base/classes/base_error_messages_english.php';
// reserved path groups: [97, 99, 100, 102, 109, 115, 116, 120, 121].
const RESERVED_PATH_GROUP = [c_base_ascii::LOWER_A, c_base_ascii::LOWER_C, c_base_ascii::LOWER_D, c_base_ascii::LOWER_F, c_base_ascii::LOWER_M, c_base_ascii::LOWER_S, c_base_ascii::LOWER_T, c_base_ascii::LOWER_U, c_base_ascii::LOWER_X];
// In most cases, this should be expected to be defined.
private static $s_languages = NULL;
+ // Represents a language-specific error message handler static class.
+ // This assists in providing language-specific error messages.
+ private static $s_error_message_handler = NULL;
+
/**
* Set the default timezone.
}
/**
+ * Assign an error message handler.
+ *
+ * @param i_base_error_messages $error_message_handler
+ * An error message handler to assign.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ *
+ * @see: i_base_error_messages
+ */
+ public static function s_set_error_message_handler($error_message_handler) {
+ if (!($error_message_handler instanceof i_base_error_messages)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'languages', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ self::$s_error_message_handler = $error_message_handler;
+ return new c_base_return_true();
+ }
+
+ /**
* Get a date string, relative to UTC, with support for milliseconds and microseconds.
*
* Use this in place of date() to ensure consistent timestamps in UTC format, with microseconds.
$class = get_class($this->s_languages);
return c_base_return_string::s_new($class);
}
+
+ /**
+ * Get the currently assigned error message handler class.
+ *
+ * @return i_base_error_messages
+ * A class that implements i_base_error_messages.
+ *
+ * @see: i_base_error_messages
+ */
+ public static function s_get_error_message_handler() {
+ if (is_null(self::$s_error_message_handler)) {
+ require_once(self::ERROR_MESSAGE_HANDLER_PATH_DEFAULT);
+
+ $class = self::ERROR_MESSAGE_HANDLER_CLASS_DEFAULT;
+ self::$s_error_message_handler = new $class();
+ unset($class);
+ }
+
+ return self::$s_error_message_handler;
+ }
+
+ /**
+ * Get the assigned error message handler.
+ *
+ * @return i_base_error_messages
+ * The assigned error message or NULL if unassigned.
+ *
+ * @see: i_base_error_messages
+ */
+ public static function s_get_error_message_handler_class() {
+ if (is_null(self::$s_error_message_handler)) {
+ require_once(self::ERROR_MESSAGE_HANDLER_PATH_DEFAULT);
+
+ $class = self::ERROR_MESSAGE_HANDLER_CLASS_DEFAULT;
+ self::$s_error_message_handler = new $class();
+ return c_base_return_string::s_new($class);
+ }
+
+ $class = get_class(self::$s_error_message_handler);
+ return c_base_return_string::s_new($class);
+ }
}
* The error message code.
* @param bool $arguments
* (optional) When TRUE, argument placeholders are added.
- * When FALSE, no placeholders are provided.
+ * When FALSE, no placeholders are added.
* All placeholders should begin with a single colon ':' and be wrapped within '{}', such that 'example' placeholder is ':{example}'.
+ * @param bool $error_message
+ * (optional) When TRUE, a reserved ':{error_message}' placeholder is added.
+ * This placeholder is processed independent of the $arguments parameter.
+ * When FALSE, the reserved placeholder is not added.
+ * If NULL, then error_message is auto-added depending on the existance of an attached error message.
* @param bool $function_name
* (optional) When TRUE, the function name is included with the message.
* When FALSE, no funciton name is provided.
*
* @see: s_get_message()
*/
- static function s_render_error_message($error, $arguments = TRUE, $function_name = FALSE, $additional_message = NULL, $html = TRUE);
+ static function s_render_error_message($error, $arguments = TRUE, $error_message = NULL, $function_name = FALSE, $additional_message = NULL, $html = TRUE);
/**
* Returns a standard error message associated with the given code.
* The error message code.
* @param bool $arguments
* (optional) When TRUE, argument placeholders are added.
- * When FALSE, no placeholders are provided.
- * All placeholders should begin with a single colon ':'.
+ * When FALSE, no placeholders are added.
+ * All placeholders should begin with a single colon ':' and be wrapped within '{}', such that 'example' placeholder is ':{example}'.
+ * @param bool $error_message
+ * (optional) When TRUE, a reserved ':{error_message}' placeholder is added.
+ * This placeholder is processed independent of the $arguments parameter.
+ * When FALSE, the reserved placeholder is not added.
+ * @param bool $function_name
+ * (optional) When TRUE, the function name is included with the message.
+ * When FALSE, no funciton name is provided.
*
* @return string
* An error message associated with the error code.
* An empty sting is returned for unsupported or unknown codes.
*/
- static function s_get_message($code);
+ static function s_get_message($code, $arguments = TRUE, $error_message = TRUE, $function_name = FALSE);
}
final class c_base_error_messages_english implements i_base_error_messages {
/**
- * Converts a given error message into a processed string.
- *
- * @param c_base_error $code
- * The error message code.
- * @param bool $arguments
- * (optional) When TRUE, argument placeholders are added.
- * When FALSE, no placeholders are provided.
- * All placeholders should begin with a single colon ':'.
- * @param bool $function_name
- * (optional) When TRUE, the function name is included with the message.
- * When FALSE, no funciton name is provided.
- * @param null|string $additional_message
- * (optional) Any additional messages to display.
- * @param bool $use_html
- * (optional) When TRUE, the message is escaped and then wrapped in HTML.
- * When FALSE, no HTML wrapping or escaping is peformed.
- *
- * @return c_base_return_string
- * A processed string is returned on success.
- * FALSE with error bit set is returned on error.
- *
- * @see: s_get_message()
+ * Implements i_base_error_messages().
*/
- static function s_render_error_message($error, $arguments = TRUE, $function_name = FALSE, $additional_message = NULL, $html = TRUE) {
+ static function s_render_error_message($error, $arguments = TRUE, $error_message = NULL, $function_name = FALSE, $additional_message = NULL, $html = TRUE) {
if (!($error instanceof c_base_error)) {
return c_base_return_string::s_new('');
}
return c_base_return_string::s_new('');
}
- $message = self::s_get_message($code, $arguments, $function_name)->get_value_exact();
+ $display_error_message = $error_message;
+ if (is_null($error_message)) {
+ if (strlen($error->get_message()) > 0) {
+ $display_error_message = TRUE;
+ }
+ else {
+ $display_error_message = FALSE;
+ }
+ }
+
+ $message = self::s_get_message($code, $arguments, $display_error_message, $function_name)->get_value_exact();
if (is_string($additional_message)) {
$message .= $additional_message;
}
+ unset($display_error_message);
if (empty($message)) {
unset($message);
if (isset($details['arguments']) && is_array($details['arguments'])) {
if ($html) {
-
foreach ($details['arguments'] as $detail_name => $detail_value) {
if (!is_string($detail_value)) {
$detail_value = '';
}
/**
- * Returns a standard error message associated with the given code.
- *
- * @param int $code
- * The error message code.
- * @param bool $arguments
- * (optional) When TRUE, argument placeholders are added.
- * When FALSE, no placeholders are provided.
- * All placeholders should begin with a single colon ':'.
- * @param bool $function_name
- * (optional) When TRUE, the function name is included with the message.
- * When FALSE, no funciton name is provided.
- *
- * @return c_base_return_string
- * A processed string is returned on success.
- * FALSE with error bit set is returned on error.
+ * @Implements s_get_message().
*/
- static function s_get_message($code, $arguments = TRUE, $function_name = FALSE) {
+ static function s_get_message($code, $arguments = TRUE, $error_message = TRUE, $function_name = FALSE) {
+ $function_name_prepend = NULL;
$function_name_string = NULL;
if ($function_name) {
+ $function_name_prepend = ',';
$function_name_string = ' while calling :{function_name}';
}
+ $error_message_string = NULL;
+ if ($error_message) {
+ $error_message_string = ', reasons: :{error_message}';
+ }
+
if ($code === static::INVALID_ARGUMENT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('An invalid argument, :{argument_name}, has been specified' . $function_name_string . '.');
+ return c_base_return_string::s_new('An invalid argument, :{argument_name}, has been specified' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('An invalid argument has been specified' . $function_name_string . '.');
+ return c_base_return_string::s_new('An invalid argument has been specified' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::INVALID_FORMAT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The argument, :{format_name}, has an invalid format' . $function_name_string . '.:{expected_format}');
+ return c_base_return_string::s_new('The argument, :{format_name}, has an invalid format' . $function_name_string . $error_message_string . '.:{expected_format}');
}
else {
- return c_base_return_string::s_new('An invalid format has been specified.');
+ return c_base_return_string::s_new('An invalid format has been specified' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::INVALID_SESSION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The requested session is invalid' . $function_name_string . '.');
+ return c_base_return_string::s_new('The requested session is invalid' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('The requested session is invalid.');
+ return c_base_return_string::s_new('The requested session is invalid' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::INVALID_VARIABLE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The variable, :{variable_name}, is invalid' . $function_name_string . '.');
+ return c_base_return_string::s_new('The variable, :{variable_name}, is invalid' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('An invalid variable has been specified.');
+ return c_base_return_string::s_new('An invalid variable has been specified' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::OPERATION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Failed to perform operation, :{operation_name}' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Failed to perform operation, :{operation_name}' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Failed to perform operation.');
+ return c_base_return_string::s_new('Failed to perform operation' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::OPERATION_UNECESSARY) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Did not perform unnecessary operation, :{operation_name}' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Did not perform unnecessary operation, :{operation_name}' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Did not perform unnecessary operation.');
+ return c_base_return_string::s_new('Did not perform unnecessary operation' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::FUNCTION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The function, :{function_name}, has failed execution.');
+ return c_base_return_string::s_new('The function, :{function_name}, has failed execution' . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('A function has failed execution.');
+ return c_base_return_string::s_new('A function has failed execution' . $error_message_string . '.');
}
}
elseif ($code === static::NOT_FOUND) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Not found' . $function_name_string . '.');
+ return c_base_return_string::s_new('Not found' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Not found.');
+ return c_base_return_string::s_new('Not found' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::NOT_FOUND_ARRAY_INDEX) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The index, :{index_name}, was not found in the array, :{array_name}' . $function_name_string . '.');
+ return c_base_return_string::s_new('The index, :{index_name}, was not found in the array, :{array_name}' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Failed to find index within specified array.');
+ return c_base_return_string::s_new('Failed to find index within specified array' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::NOT_FOUND_FILE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The file, :{file_name}, was not found or cannot be accessed' . $function_name_string . '.');
+ return c_base_return_string::s_new('The file, :{file_name}, was not found or cannot be accessed' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('File not found or cannot be accessed.');
+ return c_base_return_string::s_new('File not found or cannot be accessed' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::NOT_FOUND_DIRECTORY) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The directory, :{directory_name}, was not found or cannot be accessed' . $function_name_string . '.');
+ return c_base_return_string::s_new('The directory, :{directory_name}, was not found or cannot be accessed' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('File not found or cannot be accessed.');
+ return c_base_return_string::s_new('File not found or cannot be accessed' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::NOT_FOUND_PATH) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The path, :{path_name}, was not found or cannot be accessed' . $function_name_string . '.');
+ return c_base_return_string::s_new('The path, :{path_name}, was not found or cannot be accessed' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Path not found or cannot be accessed.');
+ return c_base_return_string::s_new('Path not found or cannot be accessed' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::NOT_DEFINED) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The requested data, :{data_name}, is not defined' . $function_name_string . '.');
+ return c_base_return_string::s_new('The requested data, :{data_name}, is not defined' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('The requested data is not defined.');
+ return c_base_return_string::s_new('The requested data is not defined' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::NO_CONNECTION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The resource, :{resource_name}, is not connected' . $function_name_string . '.');
+ return c_base_return_string::s_new('The resource, :{resource_name}, is not connected' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('The resource is not connected.');
+ return c_base_return_string::s_new('The resource is not connected' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::NO_SUPPORT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The functionality, :{functionality_name}, is currently not supported.' . $function_name_string . '.');
+ return c_base_return_string::s_new('The functionality, :{functionality_name}, is currently not supported.' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('The requested functionality is not supported.');
+ return c_base_return_string::s_new('The requested functionality is not supported' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::POSTGRESQL_CONNECTION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Failed to connect to the database, :{database_name}, reasons: :{error_message}' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Failed to connect to the database, :{database_name}' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Failed to connect to the database.');
+ return c_base_return_string::s_new('Failed to connect to the database' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::POSTGRESQL_NO_ACCOUNT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Database access denied: the account :{database_account} does not exist or does not have the required access, reasons: :{error_message}' . $function_name_string . '.');
+ return c_base_return_string::s_new('Database access denied: the account :{database_account} does not exist or does not have the required access' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Database access denied: the account does not exist or does not have the required access.');
+ return c_base_return_string::s_new('Database access denied: the account does not exist or does not have the required access' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::POSTGRESQL_NO_CONNECTION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('The database, :{database_name}, is not connected' . $function_name_string . '.');
+ return c_base_return_string::s_new('The database, :{database_name}, is not connected' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('The database is not connected.');
+ return c_base_return_string::s_new('The database is not connected' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::POSTGRESQL_NO_RESOURCE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('No database resource is available' . $function_name_string . '.');
+ return c_base_return_string::s_new('No database resource is available' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('No database resource is available.');
+ return c_base_return_string::s_new('No database resource is available' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::POSTGRESQL_ERROR) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Database query error: :{database_error_message}' . $function_name_string . '.');
+ return c_base_return_string::s_new('Database query error: :{database_error_message}' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Failed to perform database query.');
+ return c_base_return_string::s_new('Failed to perform database query' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::SOCKET_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Failed to perform socket operation, :{operation_name}, socket error (:{socket_error}) \':{socket_error_message}\'' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Failed to perform socket operation, :{operation_name}, socket error (:{socket_error}) \':{socket_error_message}\'' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Failed to perform socket operation.');
+ return c_base_return_string::s_new('Failed to perform socket operation' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::ACCESS_DENIED) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Access is denied, :{operation_name}' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Access is denied, :{operation_name}' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Access is denied.');
+ return c_base_return_string::s_new('Access is denied' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::ACCESS_DENIED_UNAVAILABLE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Access is denied due to unavailability, :{operation_name} ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Access is denied due to unavailability, :{operation_name} ' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Access is denied due to unavailability.');
+ return c_base_return_string::s_new('Access is denied due to unavailability' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::ACCESS_DENIED_USER) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Access is denied for user :name_machine_user (:{id_user}), :{operation_name} ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Access is denied for user :name_machine_user (:{id_user}), :{operation_name} ' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Access is denied for user.');
+ return c_base_return_string::s_new('Access is denied for user' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::ACCESS_DENIED_ADMINISTRATION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('Access is denied for administrative reasons, :{operation_name} ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('Access is denied for administrative reasons, :{operation_name} ' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('Access is denied for administrative reasons.');
+ return c_base_return_string::s_new('Access is denied for administrative reasons' . $function_name_string . $error_message_string . '.');
}
}
elseif ($code === static::SERVER_ERROR) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('A server error has occurred, :{operation_name} ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.');
+ return c_base_return_string::s_new('A server error has occurred, :{operation_name} ' . $function_name_prepend . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('A server error has occurred.');
+ return c_base_return_string::s_new('A server error has occurred' . $function_name_string . $error_message_string . '.');
}
}
final class c_base_error_messages_japanese implements i_base_error_messages {
/**
- * Converts a given error message into a processed string.
- *
- * @param c_base_error $code
- * The error message code.
- * @param bool $arguments
- * (optional) When TRUE, argument placeholders are added.
- * When FALSE, no placeholders are provided.
- * All placeholders should begin with a single colon ':'.
- * @param bool $function_name
- * (optional) When TRUE, the function name is included with the message.
- * When FALSE, no funciton name is provided.
- * @param null|string $additional_message
- * (optional) Any additional messages to display.
- * @param bool $use_html
- * (optional) When TRUE, the message is escaped and then wrapped in HTML.
- * When FALSE, no HTML wrapping or escaping is peformed.
- *
- * @return c_base_return_string
- * A processed string is returned on success.
- * FALSE with error bit set is returned on error.
- *
- * @see: s_get_message()
+ * Implements i_base_error_messages().
*/
- static function s_render_error_message($error, $arguments = TRUE, $function_name = FALSE, $additional_message = NULL, $html = TRUE) {
+ static function s_render_error_message($error, $arguments = TRUE, $error_message = NULL, $function_name = FALSE, $additional_message = NULL, $html = TRUE) {
if (!($error instanceof c_base_error)) {
return c_base_return_string::s_new('');
}
return c_base_return_string::s_new('');
}
- $message = self::s_get_message($code, $arguments, $function_name)->get_value_exact();
+ $display_error_message = $error_message;
+ if (is_null($error_message)) {
+ if (strlen($error->get_message()) > 0) {
+ $display_error_message = TRUE;
+ }
+ else {
+ $display_error_message = FALSE;
+ }
+ }
+
+ $message = self::s_get_message($code, $arguments, $display_error_message, $function_name)->get_value_exact();
if (is_string($additional_message)) {
$message .= $additional_message;
}
+ unset($display_error_message);
if (empty($message)) {
unset($message);
}
/**
- * Returns a standard error message associated with the given code.
- *
- * @param int $code
- * The error message code.
- * @param bool $arguments
- * (optional) When TRUE, argument placeholders are added.
- * When FALSE, no placeholders are provided.
- * All placeholders should begin with a single colon ':'.
- * @param bool $function_name
- * (optional) When TRUE, the function name is included with the message.
- * When FALSE, no funciton name is provided.
- *
- * @return c_base_return_string
- * A processed string is returned on success.
- * FALSE with error bit set is returned on error.
+ * @Implements s_get_message().
*/
- static function s_get_message($code, $arguments = TRUE, $function_name = FALSE) {
+ static function s_get_message($code, $arguments = TRUE, $error_message = TRUE, $function_name = FALSE) {
+ $function_name_prepend = NULL;
$function_name_string = NULL;
if ($function_name) {
+ $function_name_prepend = '、';
$function_name_string = ' :{function_name} を呼び出している間';
}
+ $error_message_string = NULL;
+ if ($error_message) {
+ $error_message_string = '、理由: :{error_message}';
+ }
+
if ($code === static::INVALID_ARGUMENT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('無効な引数 :{argument_name} が指定されています' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('無効な引数 :{argument_name} が指定されています' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('無効な引数が指定されています' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('無効な引数が指定されています' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::INVALID_FORMAT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('引数 :{format_name} の形式が無効です' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。:{expected_format}');
+ return c_base_return_string::s_new('引数 :{format_name} の形式が無効です' . $function_name_prepend . $function_name_string . $error_message_string . '。:{expected_format}');
}
else {
- return c_base_return_string::s_new('無効な形式が指定されています。');
+ return c_base_return_string::s_new('無効な形式が指定されています' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::INVALID_SESSION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('要求されたセッションは無効です' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('要求されたセッションは無効です' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('要求されたセッションは無効です。');
+ return c_base_return_string::s_new('要求されたセッションは無効です' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::INVALID_VARIABLE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('変数 :{variable_name} は無効です' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('変数 :{variable_name} は無効です' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('無効な変数が指定されています。');
+ return c_base_return_string::s_new('無効な変数が指定されています' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::OPERATION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('操作の実行に失敗しました :{operation_name}' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('操作の実行に失敗しました :{operation_name}' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('操作を実行できませんでした。');
+ return c_base_return_string::s_new('操作を実行できませんでした' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::OPERATION_UNECESSARY) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('不要な操作を実行しませんでした :{operation_name}' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('不要な操作を実行しませんでした :{operation_name}' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('不要な操作を実行しませんでした。');
+ return c_base_return_string::s_new('不要な操作を実行しませんでした' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::FUNCTION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('関数 :{function_name} は実行に失敗しました' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('関数 :{function_name} は実行に失敗しました' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('関数の実行に失敗しました。');
+ return c_base_return_string::s_new('関数の実行に失敗しました' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::NOT_FOUND) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('見つかりません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('見つかりません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('見つかりません。');
+ return c_base_return_string::s_new('見つかりません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::NOT_FOUND_ARRAY_INDEX) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('配列 :{index_name} に索引 :{array_name} が見つかりませんでした' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('配列 :{index_name} に索引 :{array_name} が見つかりませんでした' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('指定された配列内のインデックスの検索に失敗しました。');
+ return c_base_return_string::s_new('指定された配列内のインデックスの検索に失敗しました' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::NOT_FOUND_FILE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('ファイル :{file_name} が見つかりませんでした、またはアクセスできません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('ファイル :{file_name} が見つかりませんでした、またはアクセスできません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('ファイルが見つからないか、アクセスできません。');
+ return c_base_return_string::s_new('ファイルが見つからないか、アクセスできません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::NOT_FOUND_DIRECTORY) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('ディレクトリ :{directory_name} が見つかりませんでした、またはアクセスできません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('ディレクトリ :{directory_name} が見つかりませんでした、またはアクセスできません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('ファイルが見つからないか、アクセスできません。');
+ return c_base_return_string::s_new('ファイルが見つからないか、アクセスできません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::NOT_FOUND_FILE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('パス :{path_name} が見つかりませんでした' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('パス :{path_name} が見つかりませんでした' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('パスが見つかりません。');
+ return c_base_return_string::s_new('パスが見つかりません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::NOT_DEFINED) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('要求されたデータ:{data_name}は定義されていません' . $function_name_string . '.');
+ return c_base_return_string::s_new('要求されたデータ:{data_name}は定義されていません' . $function_name_string . $error_message_string . '.');
}
else {
- return c_base_return_string::s_new('要求されたデータは定義されていません。');
+ return c_base_return_string::s_new('要求されたデータは定義されていません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::NO_CONNECTION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('リソース :{resource_name} は接続されていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('リソース :{resource_name} は接続されていません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('リソースが接続されていません。');
+ return c_base_return_string::s_new('リソースが接続されていません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::NO_SUPPORT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('機能 :{functionality_name} は現在サポートされていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('機能 :{functionality_name} は現在サポートされていません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('要求された機能はサポートされていません。');
+ return c_base_return_string::s_new('要求された機能はサポートされていません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::POSTGRESQL_CONNECTION_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('データベースへの接続に失敗しました。 :{database_name}' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('データベースへの接続に失敗しました。 :{database_name}' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('データベースに接続できませんでした。');
+ return c_base_return_string::s_new('データベースに接続できませんでした' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::POSTGRESQL_NO_ACCOUNT) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('データベースアクセスが拒否されました:アカウント:{database_account}が存在しないか、必要なアクセス権' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('データベースアクセスが拒否されました:アカウント:{database_account}が存在しないか、必要なアクセス権' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('データベースアクセスが拒否されました:アカウントが存在しないか、必要なアクセス権がありません ');
+ return c_base_return_string::s_new('データベースアクセスが拒否されました:アカウントが存在しないか、必要なアクセス権がありません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::POSTGRESQL_NO_CONNECTION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('データベース :{database_name} は接続されていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('データベース :{database_name} は接続されていません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('データベースが接続されていません。');
+ return c_base_return_string::s_new('データベースが接続されていません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::POSTGRESQL_NO_RESOURCE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('データベースリソースがありません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('データベースリソースがありません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('データベースリソースは使用できません。.');
+ return c_base_return_string::s_new('データベースリソースは使用できません' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::SOCKET_FAILURE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('ソケット操作の実行に失敗しました。 :{operation_name} 、ソケットエラー(:{socket_error} \':{socket_error_message}\'' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('ソケット操作の実行に失敗しました。 :{operation_name} 、ソケットエラー(:{socket_error} \':{socket_error_message}\'' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('ソケット操作を実行できませんでした。');
+ return c_base_return_string::s_new('ソケット操作を実行できませんでした' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::ACCESS_DENIED) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('アクセスが拒否されました。 :{operation_name}' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('アクセスが拒否されました。 :{operation_name}' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('アクセスは拒否されました。');
+ return c_base_return_string::s_new('アクセスは拒否されました' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::ACCESS_DENIED_UNAVAILABLE) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('利用できないためアクセスが拒否されましたが、 :{operation_name} ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('利用できないためアクセスが拒否されましたが、 :{operation_name} ' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('利用できないためアクセスが拒否されました。');
+ return c_base_return_string::s_new('利用できないためアクセスが拒否されました' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::ACCESS_DENIED_USER) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('ユーザーのアクセスが拒否されました :name_machine_user (:{id_user}), :{operation_name} ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('ユーザーのアクセスが拒否されました :name_machine_user (:{id_user}), :{operation_name} ' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('ユーザーのアクセスが拒否されました。');
+ return c_base_return_string::s_new('ユーザーのアクセスが拒否されました' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::ACCESS_DENIED_ADMINISTRATION) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('管理上の理由でアクセスが拒否されました, :{operation_name} ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('管理上の理由でアクセスが拒否されました, :{operation_name} ' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('管理上の理由からアクセスが拒否されました。');
+ return c_base_return_string::s_new('管理上の理由からアクセスが拒否されました' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
elseif ($code === static::SERVER_ERROR) {
if ($arguments === TRUE) {
- return c_base_return_string::s_new('サーバーエラーが発生しました, :{operation_name} ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
+ return c_base_return_string::s_new('サーバーエラーが発生しました, :{operation_name} ' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
else {
- return c_base_return_string::s_new('サーバーエラーが発生しました。');
+ return c_base_return_string::s_new('サーバーエラーが発生しました' . $function_name_prepend . $function_name_string . $error_message_string . '。');
}
}
* Assign the message.
*/
public function set_message($message) {
+ if (!is_string($message)) {
+ return;
+ }
+
$this->message = $message;
}
// load database session information.
$user_current = new c_standard_users_user();
- if ($user_current->do_load($this->database) instanceof c_base_return_true) {
+ $database_loaded = $user_current->do_load($this->database);
+ if ($database_loaded instanceof c_base_return_true) {
+ unset($database_loaded);
+
$this->session->set_user_current($user_current);
}
else {
+ if (c_base_return::s_has_error($database_loaded)) {
+ $error_message = $database_loaded->get_error(0);
+ }
+ else {
+ $error_message = NULL;
+ }
+ unset($database_loaded);
+
$account_name = $user_current->get_name_machine();
if ($account_name instanceof c_base_return_string) {
$account_name = $account_name->get_value_exact();
$account_name = '';
}
- $error = c_base_error::s_log(NULL, ['arguments' => [':{database_account}' => $account_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::POSTGRESQL_NO_ACCOUNT);
+ $error = c_base_error::s_log($error_message, ['arguments' => [':{database_account}' => $account_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::POSTGRESQL_NO_ACCOUNT);
unset($account_name);
+ unset($error_message);
return c_base_return_error::s_false($error);
}
* The error message code.
* @param bool $arguments
* (optional) When TRUE, argument placeholders are added.
- * When FALSE, no placeholders are provided.
+ * When FALSE, no placeholders are added.
* All placeholders should begin with a single colon ':' and be wrapped within '{}', such that 'example' placeholder is ':{example}'.
+ * @param bool $error_message
+ * (optional) When TRUE, a reserved ':{error_message}' placeholder is added.
+ * This placeholder is processed independent of the $arguments parameter.
+ * When FALSE, the reserved placeholder is not added.
+ * If NULL, then error_message is auto-added depending on the existance of an attached error message.
* @param bool $function_name
* (optional) When TRUE, the function name is included with the message.
* When FALSE, no funciton name is provided.
*
* @see: s_get_message()
*/
- protected function pr_get_error_text($error, $arguments = TRUE, $function_name = FALSE, $additional_message = NULL, $html = FALSE) {
+ protected function pr_get_error_text($error, $arguments = TRUE, $error_message = NULL, $function_name = FALSE, $additional_message = NULL, $html = FALSE) {
if (!($error instanceof c_base_error)) {
return new c_base_return_false();
}
- return c_base_return_string::s_new('');
+ return c_base_defaults_global::s_get_error_message_handler()::s_render_error_message($error, $arguments, $error_message, $function_name, $additional_message, $html);
}
/**
* Implements c_standard_path_server_error().
*/
final class c_standard_path_server_error_ja extends c_standard_path_server_error {
-
/**
* Implements pr_get_error_text().
*/
- protected function pr_get_error_text($error, $arguments = TRUE, $function_name = FALSE, $additional_message = NULL, $html = FALSE) {
+ protected function pr_get_error_text($error, $arguments = TRUE, $error_message = NULL, $function_name = FALSE, $additional_message = NULL, $html = FALSE) {
if (!($error instanceof c_base_error)) {
return new c_base_return_false();
}
require_once('common/base/classes/base_error_messages_japanese.php');
- return c_base_error_messages_japanese::s_render_error_message($error, $arguments, $function_name, $additional_message, $html);
+
+ return c_base_error_messages_japanese::s_render_error_message($error, $arguments, $error_message, $function_name, $additional_message, $html);
}
/**
}
/**
- * Implements pr_get_error_text().
- */
- protected function pr_get_error_text($error, $arguments = TRUE, $function_name = FALSE, $additional_message = NULL, $html = FALSE) {
- if (!($error instanceof c_base_error)) {
- return new c_base_return_false();
- }
-
- require_once('common/base/classes/base_error_messages_english.php');
- return c_base_error_messages_english::s_render_error_message($error, $arguments, $function_name, $additional_message, $html);
- }
-
- /**
* Implements pr_get_text().
*/
protected function pr_get_text($code, $arguments = []) {
$error = reset($errors);
unset($errors);
- $error_messsage = $error->get_message();
+ $error_message = $error->get_message();
unset($error);
if (is_string($error_message)) {
*/
namespace n_koopa;
-
/**
* A collection of global settings for use by the entire project.
*
* This is intended to be modified by the developers or site developers of a project.
*
- * Warning: Any variables defined here (due to being global) must be considered not thread-safe.
+ * Warning: Any variables defined here (due to being global) must be considered non-thread-safe.
* Be sure to handle carefully when using threads.
* It is recommended to process and pre-set as much of this as possible before starting threads.
*/
// provide a language to fallback to if none is set.
const LANGUAGE_CLASS_DEFAULT = '\n_koopa\c_base_languages_limited';
+ // provide an error message handler to fallback to if none is set.
+ const ERROR_MESSAGE_HANDLER_CLASS_DEFAULT = '\n_koopa\c_base_error_messages_english';
+
+ // provide the include path for the default/fallback error message handler class.
+ const ERROR_MESSAGE_HANDLER_PATH_DEFAULT = 'common/base/classes/base_error_messages_english.php';
+
// reserved path groups: [97, 99, 100, 102, 109, 115, 116, 120, 121].
const RESERVED_PATH_GROUP = [c_base_ascii::LOWER_A, c_base_ascii::LOWER_C, c_base_ascii::LOWER_D, c_base_ascii::LOWER_F, c_base_ascii::LOWER_M, c_base_ascii::LOWER_S, c_base_ascii::LOWER_T, c_base_ascii::LOWER_U, c_base_ascii::LOWER_X];
// In most cases, this should be expected to be defined.
private static $s_languages = NULL;
+ // Represents a language-specific error message handler static class.
+ // This assists in providing language-specific error messages.
+ private static $s_error_message_handler = NULL;
+
/**
* Set the default timezone.
}
/**
+ * Assign an error message handler.
+ *
+ * @param i_base_error_messages $error_message_handler
+ * An error message handler to assign.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ *
+ * @see: i_base_error_messages
+ */
+ public static function s_set_error_message_handler($error_message_handler) {
+ if (!($error_message_handler instanceof i_base_error_messages)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'languages', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ self::$s_error_message_handler = $error_message_handler;
+ return new c_base_return_true();
+ }
+
+ /**
* Get a date string, relative to UTC, with support for milliseconds and microseconds.
*
* Use this in place of date() to ensure consistent timestamps in UTC format, with microseconds.
$class = get_class($this->s_languages);
return c_base_return_string::s_new($class);
}
+
+ /**
+ * Get the currently assigned error message handler class.
+ *
+ * @return i_base_error_messages
+ * A class that implements i_base_error_messages.
+ *
+ * @see: i_base_error_messages
+ */
+ public static function s_get_error_message_handler() {
+ if (is_null(self::$s_error_message_handler)) {
+ require_once(self::ERROR_MESSAGE_HANDLER_PATH_DEFAULT);
+
+ $class = self::ERROR_MESSAGE_HANDLER_CLASS_DEFAULT;
+ self::$s_error_message_handler = new $class();
+ unset($class);
+ }
+
+ return self::$s_error_message_handler;
+ }
+
+ /**
+ * Get the assigned error message handler.
+ *
+ * @return i_base_error_messages
+ * The assigned error message or NULL if unassigned.
+ *
+ * @see: i_base_error_messages
+ */
+ public static function s_get_error_message_handler_class() {
+ if (is_null(self::$s_error_message_handler)) {
+ require_once(self::ERROR_MESSAGE_HANDLER_PATH_DEFAULT);
+
+ $class = self::ERROR_MESSAGE_HANDLER_CLASS_DEFAULT;
+ self::$s_error_message_handler = new $class();
+ return c_base_return_string::s_new($class);
+ }
+
+ $class = get_class(self::$s_error_message_handler);
+ return c_base_return_string::s_new($class);
+ }
}