*/
abstract class BSApi
{
+ /**
+ * The callback function for the error handler
+ * @var string
+ */
+ public static $errorHandler;
+
/**
* Fields: used for verification and sanitization
* NAME => array(TYPE, REQUIRED, VERIFY METHOD (:self for self-named method), RELATION => array(FILE, CLASS IN FILE, ALTERNATE FIELD NAME))
private function _processErrorQueue()
{
// we want to explicitly specify silence
- if (APIError() == 'silent')
+ if (self::$errorHandler == 'silent')
{
return;
}
- if (!is_callable(APIError()))
+ if (!is_callable(self::$errorHandler))
{
- trigger_error('No APIError() handler has been set');
+ throw new Exception('No BSApi::$errorHandler handler has been set');
}
foreach ($this->errors AS $e)
{
- call_user_func(APIError(), $e);
+ call_user_func(BSApi::$errorHandler, $e);
}
}
{
if (!isset($this->fields["$field"]))
{
- trigger_error('Field "' . $field . '" is not valid');
+ throw new Exception('Field "' . $field . '" is not valid');
return;
}
{
if (!$this->values["$field"])
{
- trigger_error('The specified field "' . $field . '" for the condition could not be found as it is not set');
+ throw new Exception('The specified field "' . $field . '" for the condition could not be found as it is not set');
continue;
}
{
if (!$this->values["$name"])
{
- trigger_error('Cannot determine condition from the REQ_AUTO field because it is not set');
+ throw new Exception('Cannot determine condition from the REQ_AUTO field because it is not set');
continue;
}
if ($this->condition == '')
{
- trigger_error('No REQ_AUTO fields are present and therefore the condition cannot be created');
+ throw new Exception('No REQ_AUTO fields are present and therefore the condition cannot be created');
}
}
}
}
}
-// ###################################################################
-/**
-* Setter and getter method for the API error reporting system. Passing
-* a name will cause the set, no arguments will cause the get.
-*
-* @param mixed Method name in callable form
-*
-* @return mixed Method name in callable form
-*/
-function APIError($new = null)
-{
- static $caller, $prev;
-
- if ($new === -1)
- {
- $caller = $prev;
- }
- else if ($new !== null)
- {
- $prev = $caller;
- $caller = $new;
- }
-
- return $caller;
-}
-
?>
\ No newline at end of file