From 16a704ce8a1449cbee22fb13bd32508c975fac9f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Nov 2012 17:25:00 +0200 Subject: [ci skip] Polish docs in user_guide_src/source/general/ --- user_guide_src/source/general/errors.rst | 66 +++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'user_guide_src/source/general/errors.rst') diff --git a/user_guide_src/source/general/errors.rst b/user_guide_src/source/general/errors.rst index 91b59140f..8c941aadb 100644 --- a/user_guide_src/source/general/errors.rst +++ b/user_guide_src/source/general/errors.rst @@ -20,47 +20,69 @@ without having to worry about class/function scoping. The following functions let you generate errors: -show_error('message' [, int $status_code= 500 ] ) -=================================================== +show_error() +============ + +.. php:function:: show_error($message, $status_code, $heading = 'An Error Was Encountered') + + :param mixed $message: Error message + :param int $status_code: HTTP Response status code + :param string $heading: Error page heading + :returns: void This function will display the error message supplied to it using the -following error template: +following error template:: + + application/errors/error_general.php + +The optional parameter ``$status_code`` determines what HTTP status +code should be sent with the error. -application/errors/error_general.php +show_404() +========== -The optional parameter $status_code determines what HTTP status code -should be sent with the error. +.. php:function:: show_404($page = '', $log_error = TRUE) -show_404('page' [, 'log_error']) -================================== + :param string $page: URI string + :param bool $log_error: Whether to log the error + :returns: void This function will display the 404 error message supplied to it using -the following error template: +the following error template:: -application/errors/error_404.php + application/errors/error_404.php The function expects the string passed to it to be the file path to the page that isn't found. Note that CodeIgniter automatically shows 404 messages if controllers are not found. -CodeIgniter automatically logs any show_404() calls. Setting the +CodeIgniter automatically logs any ``show_404()`` calls. Setting the optional second parameter to FALSE will skip logging. -log_message('level', 'message') -================================ +log_message() +============= + +.. php:function:: log_message($level = 'error', $message, $php_error = FALSE) + + :param string $level: Log level + :param string $message: Message to log + :param bool $php_error: Whether we're loggin a native PHP error message + :returns: void This function lets you write messages to your log files. You must supply one of three "levels" in the first parameter, indicating what type of message it is (debug, error, info), with the message itself in the -second parameter. Example:: +second parameter. + +Example:: - if ($some_var == "") + if ($some_var == '') { - log_message('error', 'Some variable did not contain a value.'); + log_message('error', 'Some variable did not contain a value.'); } else { - log_message('debug', 'Some variable was correctly set'); + log_message('debug', 'Some variable was correctly set'); } log_message('info', 'The purpose of some variable is to provide some value.'); @@ -77,8 +99,8 @@ There are three message types: natively generate any info messages but you may want to in your application. -.. note:: In order for the log file to actually be written, the "logs" - folder must be writable. In addition, you must set the "threshold" for - logging in application/config/config.php. You might, for example, only - want error messages to be logged, and not the other two types. If you - set it to zero logging will be disabled. +.. note:: In order for the log file to actually be written, the *logs* + directory must be writable. In addition, you must set the "threshold" + for logging in *application/config/config.php*. You might, for example, + only want error messages to be logged, and not the other two types. + If you set it to zero logging will be disabled. \ No newline at end of file -- cgit v1.2.3-24-g4f1b