You are here

function PEAR::setErrorHandling in Calendar Systems 5

Sets how errors generated by this object should be handled. Can be invoked both in objects and statically. If called statically, setErrorHandling sets the default behaviour for all PEAR objects. If called in an object, setErrorHandling sets the default behaviour for that object.

@access public

@since PHP 4.0.5

Parameters

int $mode: One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.

mixed $options: When $mode is PEAR_ERROR_TRIGGER, this is the error level (one of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).

When $mode is PEAR_ERROR_CALLBACK, this parameter is expected to be the callback function or method. A callback function is a string with the name of the function, a callback method is an array of two elements: the element at index 0 is the object, and the element at index 1 is the name of the method to call in the object.

When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is a printf format string used when printing the error message.

Return value

void

See also

PEAR_ERROR_RETURN

PEAR_ERROR_PRINT

PEAR_ERROR_TRIGGER

PEAR_ERROR_DIE

PEAR_ERROR_CALLBACK

PEAR_ERROR_EXCEPTION

4 calls to PEAR::setErrorHandling()
PEAR::popErrorHandling in calendar/lib/PEAR.php
Pop the last error handler used
PEAR::popErrorHandling in calendar/lib/PEAR.php
Pop the last error handler used
PEAR::pushErrorHandling in calendar/lib/PEAR.php
Push a new error handler on top of the error handler options stack. With this you can easily override the actual error handler for some code and restore it later with popErrorHandling.
PEAR::pushErrorHandling in calendar/lib/PEAR.php
Push a new error handler on top of the error handler options stack. With this you can easily override the actual error handler for some code and restore it later with popErrorHandling.

File

calendar/lib/PEAR.php, line 334

Class

PEAR
Base class for other PEAR classes. Provides rudimentary emulation of destructors.

Code

function setErrorHandling($mode = null, $options = null) {
  if (isset($this) && is_a($this, 'PEAR')) {
    $setmode =& $this->_default_error_mode;
    $setoptions =& $this->_default_error_options;
  }
  else {
    $setmode =& $GLOBALS['_PEAR_default_error_mode'];
    $setoptions =& $GLOBALS['_PEAR_default_error_options'];
  }
  switch ($mode) {
    case PEAR_ERROR_EXCEPTION:
    case PEAR_ERROR_RETURN:
    case PEAR_ERROR_PRINT:
    case PEAR_ERROR_TRIGGER:
    case PEAR_ERROR_DIE:
    case null:
      $setmode = $mode;
      $setoptions = $options;
      break;
    case PEAR_ERROR_CALLBACK:
      $setmode = $mode;

      // class/object method callback
      if (is_callable($options)) {
        $setoptions = $options;
      }
      else {
        trigger_error("invalid error callback", E_USER_WARNING);
      }
      break;
    default:
      trigger_error("invalid error mode", E_USER_WARNING);
      break;
  }
}