You are here

function PEAR::raiseError in Calendar Systems 5

This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. If the $mode and $options parameters are not specified, the object's defaults are used.

@access public

@since PHP 4.0.5

Parameters

mixed $message a text error message or a PEAR error object:

int $code a numeric error code (it is up to your class: to define these if you want to use codes)

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

mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter: specifies the PHP-internal error level (one of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). If $mode is PEAR_ERROR_CALLBACK, this parameter specifies the callback function or method. In other error modes this parameter is ignored.

string $userinfo If you need to pass along for example debug: information, this parameter is meant for that.

string $error_class The returned error object will be: instantiated from this class, if specified.

bool $skipmsg If true, raiseError will only pass error codes,: the error message parameter will be dropped.

Return value

object a PEAR error object

See also

PEAR::setErrorHandling

4 calls to PEAR::raiseError()
cmfcClassesCore::raiseError in calendar/lib/classesCore.class.inc.php
conditionally includes PEAR base class and raise an error @example <code> return $this->raiseError('', CMF_Language_Error_Unknown_Short_Name, * PEAR_ERROR_RETURN,NULL, * array('shortName'=>$shortName) …
PEAR::delExpect in calendar/lib/PEAR.php
This method deletes all occurences of the specified element from the expected error codes stack.
PEAR::throwError in calendar/lib/PEAR.php
Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.
PEAR::throwError in calendar/lib/PEAR.php
Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.
1 method overrides PEAR::raiseError()
cmfcClassesCore::raiseError in calendar/lib/classesCore.class.inc.php
conditionally includes PEAR base class and raise an error @example <code> return $this->raiseError('', CMF_Language_Error_Unknown_Short_Name, * PEAR_ERROR_RETURN,NULL, * array('shortName'=>$shortName) …

File

calendar/lib/PEAR.php, line 523

Class

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

Code

function &raiseError($message = null, $code = null, $mode = null, $options = null, $userinfo = null, $error_class = null, $skipmsg = false) {

  // The error is yet a PEAR error object
  if (is_object($message)) {
    $code = $message
      ->getCode();
    $userinfo = $message
      ->getUserInfo();
    $error_class = $message
      ->getType();
    $message->error_message_prefix = '';
    $message = $message
      ->getMessage();
  }
  if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
    if ($exp[0] == "*" || is_int(reset($exp)) && in_array($code, $exp) || is_string(reset($exp)) && in_array($message, $exp)) {
      $mode = PEAR_ERROR_RETURN;
    }
  }

  // No mode given, try global ones
  if ($mode === null) {

    // Class error handler
    if (isset($this) && isset($this->_default_error_mode)) {
      $mode = $this->_default_error_mode;
      $options = $this->_default_error_options;

      // Global error handler
    }
    elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
      $mode = $GLOBALS['_PEAR_default_error_mode'];
      $options = $GLOBALS['_PEAR_default_error_options'];
    }
  }
  if ($error_class !== null) {
    $ec = $error_class;
  }
  elseif (isset($this) && isset($this->_error_class)) {
    $ec = $this->_error_class;
  }
  else {
    $ec = 'PEAR_Error';
  }
  if ($skipmsg) {
    $a =& new $ec($code, $mode, $options, $userinfo);
    return $a;
  }
  else {
    $a =& new $ec($message, $code, $mode, $options, $userinfo);
    return $a;
  }
}