PEAR_Error [deprecated]

Table of Contents

PEAR_Error is an object created by every function in PEAR in case of a failure. It provides information on why a function fails.

How you get the object depends on PEAR::SetErrorHandling()

Constants defined in and used by PEAR_ErrorStack (Previous) add user information (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

Note by: anrdaemon@freemail.ru
Who want actual exceptions support to packages like MDB2, try this:

<?php
class ePearError extends Exception
{
  protected 
$_type;
  protected 
$_userInfo;

  function 
getType()
  {
    return 
$this->_type;
  }

  function 
getDebugInfo()
  {
    return 
$this->getUserInfo();
  }

  function 
getUserInfo()
  {
    return 
$this->_userInfo;
  }

  function 
__construct(&$errorObject)
  {
    
parent::__construct($errorObject->getMessage(), $errorObject->getCode());
    
$this->_type $errorObject->getType();
    
$this->_userInfo $errorObject->getUserInfo();
  }

  function 
__toString()
  {
    return 
sprintf('[%s: message="%s" code=%d info="%s"]'$this->getType(),
      
$this->getMessage(), $this->getCode(), $this->getUserInfo());
  }
}

function 
pearErrorCallback(&$errorObject)
{
  throw new 
ePearError($errorObject);
}

PEAR::setErrorHandling(PEAR_ERROR_CALLBACK'pearErrorCallback');

?>