From 0326755cbf8e1383ece4729995d5f5c5310e7648 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 29 Jan 2006 05:38:43 +0000 Subject: [PATCH] - Added ability to restore the APIError() to its last value - Created API->errors array to store all errors - We now allow for silent error reporting - Silenced errors can be checked using API::check_errors() --- api.php | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/api.php b/api.php index 63ec8a7..a465f75 100644 --- a/api.php +++ b/api.php @@ -160,6 +160,13 @@ class API */ var $dorelations = array('fetch'); + /** + * Error list that has been generated + * @var array + * @access private + */ + var $errors = array(); + // ################################################################### /** * Constructor: cannot instantiate class directly @@ -198,6 +205,14 @@ class API */ function error($message) { + $this->errors[] = $message; + + // we want to explicitly specify silence + if (APIError() == 'silent') + { + return; + } + if (!is_callable(APIError())) { trigger_error('No APIError() handler has been set', E_USER_WARNING); @@ -206,6 +221,26 @@ class API call_user_func(APIError(), $message); } + // ################################################################### + /** + * Returns the error list. This is because we don't want people mucking + * with the error system. It will return an empty array if there are + * no errors. + * + * @access public + * + * @return array Array of errors + */ + function check_errors() + { + if (sizeof($this->errors) < 1) + { + return array(); + } + + return $this->errors; + } + // ################################################################### /** * Sets a value, sanitizes it, and verifies it @@ -569,10 +604,15 @@ class API */ function APIError($new = null) { - static $caller; + static $caller, $prev; - if ($new !== null) + if ($new === -1) + { + $caller = $prev; + } + else if ($new !== null) { + $prev = $caller; $caller = $new; } -- 2.43.5