ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
PEAR_Error Class Reference
+ Inheritance diagram for PEAR_Error:
+ Collaboration diagram for PEAR_Error:

Public Member Functions

 PEAR_Error ($message='unknown error', $code=null, $mode=null, $options=null, $userinfo=null)
 PEAR_Error constructor. More...
 
 getMode ()
 Get the error mode from an error object. More...
 
 getCallback ()
 Get the callback function/method from an error object. More...
 
 getMessage ()
 Get the error message from an error object. More...
 
 getCode ()
 Get error code from an error object. More...
 
 getType ()
 Get the name of this error/exception. More...
 
 getUserInfo ()
 Get additional user-supplied information. More...
 
 getDebugInfo ()
 Get additional debug information supplied by the application. More...
 
 getBacktrace ($frame=null)
 Get the call backtrace from where the error was generated. More...
 
 addUserInfo ($info)
 
 __toString ()
 
 toString ()
 Make a string representation of this object. More...
 

Data Fields

 $error_message_prefix = ''
 
 $mode = PEAR_ERROR_RETURN
 
 $level = E_USER_NOTICE
 
 $code = -1
 
 $message = ''
 
 $userinfo = ''
 
 $backtrace = null
 

Detailed Description

Definition at line 826 of file PEAR.php.

Member Function Documentation

◆ __toString()

PEAR_Error::__toString ( )

Definition at line 1055 of file PEAR.php.

1056 {
1057 return $this->getMessage();
1058 }
getMessage()
Get the error message from an error object.
Definition: PEAR.php:957

References getMessage().

+ Here is the call graph for this function:

◆ addUserInfo()

PEAR_Error::addUserInfo (   $info)

Definition at line 1044 of file PEAR.php.

1045 {
1046 if (empty($this->userinfo)) {
1047 $this->userinfo = $info;
1048 } else {
1049 $this->userinfo .= " ** $info";
1050 }
1051 }
$info
Definition: example_052.php:80

References $info.

◆ getBacktrace()

PEAR_Error::getBacktrace (   $frame = null)

Get the call backtrace from where the error was generated.

Supported with PHP 4.3.0 or newer.

Parameters
int$frame(optional) what frame to fetch
Returns
array Backtrace, or NULL if not available. @access public

Definition at line 1030 of file PEAR.php.

1031 {
1032 if (defined('PEAR_IGNORE_BACKTRACE')) {
1033 return null;
1034 }
1035 if ($frame === null) {
1036 return $this->backtrace;
1037 }
1038 return $this->backtrace[$frame];
1039 }
$backtrace
Definition: PEAR.php:836

References $backtrace.

◆ getCallback()

PEAR_Error::getCallback ( )

Get the callback function/method from an error object.

Returns
mixed callback function or object/method array @access public

Definition at line 943 of file PEAR.php.

943 {
944 return $this->callback;
945 }

◆ getCode()

PEAR_Error::getCode ( )

Get error code from an error object.

Returns
int error code @access public

Definition at line 972 of file PEAR.php.

973 {
974 return $this->code;
975 }

References $code.

◆ getDebugInfo()

PEAR_Error::getDebugInfo ( )

Get additional debug information supplied by the application.

Returns
string debug information @access public

Definition at line 1014 of file PEAR.php.

1015 {
1016 return $this->getUserInfo();
1017 }
getUserInfo()
Get additional user-supplied information.
Definition: PEAR.php:1000

References getUserInfo().

+ Here is the call graph for this function:

◆ getMessage()

PEAR_Error::getMessage ( )

Get the error message from an error object.

Returns
string full error message @access public

Definition at line 957 of file PEAR.php.

958 {
959 return ($this->error_message_prefix . $this->message);
960 }

Referenced by __toString(), and PEAR_Error().

+ Here is the caller graph for this function:

◆ getMode()

PEAR_Error::getMode ( )

Get the error mode from an error object.

Returns
int error mode @access public

Definition at line 930 of file PEAR.php.

930 {
931 return $this->mode;
932 }

References $mode.

◆ getType()

PEAR_Error::getType ( )

Get the name of this error/exception.

Returns
string error/exception name (type) @access public

Definition at line 986 of file PEAR.php.

987 {
988 return get_class($this);
989 }

◆ getUserInfo()

PEAR_Error::getUserInfo ( )

Get additional user-supplied information.

Returns
string user-supplied information @access public

Definition at line 1000 of file PEAR.php.

1001 {
1002 return $this->userinfo;
1003 }

References $userinfo.

Referenced by getDebugInfo().

+ Here is the caller graph for this function:

◆ PEAR_Error()

PEAR_Error::PEAR_Error (   $message = 'unknown error',
  $code = null,
  $mode = null,
  $options = null,
  $userinfo = null 
)

PEAR_Error constructor.

Parameters
string$messagemessage
int$code(optional) error code
int$mode(optional) error mode, one of: PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
mixed$options(optional) error level, OR in the case of PEAR_ERROR_CALLBACK, the callback function or object/method tuple.
string$userinfo(optional) additional user/debug info

@access public

Definition at line 861 of file PEAR.php.

863 {
864 if ($mode === null) {
866 }
867 $this->message = $message;
868 $this->code = $code;
869 $this->mode = $mode;
870 $this->userinfo = $userinfo;
871 if (!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
872 $this->backtrace = debug_backtrace();
873 if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) {
874 unset($this->backtrace[0]['object']);
875 }
876 }
878 $this->level = E_USER_NOTICE;
879 $this->callback = $options;
880 } else {
881 if ($options === null) {
882 $options = E_USER_NOTICE;
883 }
884 $this->level = $options;
885 $this->callback = null;
886 }
887 if ($this->mode & PEAR_ERROR_PRINT) {
888 if (is_null($options) || is_int($options)) {
889 $format = "%s";
890 } else {
891 $format = $options;
892 }
893 printf($format, $this->getMessage());
894 }
895 if ($this->mode & PEAR_ERROR_TRIGGER) {
896 trigger_error($this->getMessage(), $this->level);
897 }
898 if ($this->mode & PEAR_ERROR_DIE) {
899 $msg = $this->getMessage();
900 if (is_null($options) || is_int($options)) {
901 $format = "%s";
902 if (substr($msg, -1) != "\n") {
903 $msg .= "\n";
904 }
905 } else {
906 $format = $options;
907 }
908 die(sprintf($format, $msg));
909 }
910 if ($this->mode & PEAR_ERROR_CALLBACK) {
911 if (is_callable($this->callback)) {
912 call_user_func($this->callback, $this);
913 }
914 }
915 if ($this->mode & PEAR_ERROR_EXCEPTION) {
916 trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
917 $e = new Exception($this->message, $this->code);throw($e); // no eval() necessary to throw an exception
918 }
919 }
const PEAR_ERROR_PRINT
Definition: PEAR.php:32
const PEAR_ERROR_TRIGGER
Definition: PEAR.php:33
const PEAR_ERROR_RETURN
#+ ERROR constants
Definition: PEAR.php:31
const PEAR_ERROR_EXCEPTION
WARNING: obsolete.
Definition: PEAR.php:40
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
const PEAR_ERROR_DIE
Definition: PEAR.php:34
& getStaticProperty($class, $var)
If you have a class that's mostly/entirely static, and you need static properties,...
Definition: PEAR.php:230
if(!is_array($argv)) $options

References $code, $message, $mode, $options, $userinfo, getMessage(), PEAR\getStaticProperty(), PEAR_ERROR_CALLBACK, PEAR_ERROR_DIE, PEAR_ERROR_EXCEPTION, PEAR_ERROR_PRINT, PEAR_ERROR_RETURN, and PEAR_ERROR_TRIGGER.

Referenced by IT_Error\IT_Error(), and MDB2_Error\MDB2_Error().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString()

PEAR_Error::toString ( )

Make a string representation of this object.

Returns
string a string with an object summary @access public

Definition at line 1068 of file PEAR.php.

1068 {
1069 $modes = array();
1070 $levels = array(E_USER_NOTICE => 'notice',
1071 E_USER_WARNING => 'warning',
1072 E_USER_ERROR => 'error');
1073 if ($this->mode & PEAR_ERROR_CALLBACK) {
1074 if (is_array($this->callback)) {
1075 $callback = (is_object($this->callback[0]) ?
1076 strtolower(get_class($this->callback[0])) :
1077 $this->callback[0]) . '::' .
1078 $this->callback[1];
1079 } else {
1080 $callback = $this->callback;
1081 }
1082 return sprintf('[%s: message="%s" code=%d mode=callback '.
1083 'callback=%s prefix="%s" info="%s"]',
1084 strtolower(get_class($this)), $this->message, $this->code,
1085 $callback, $this->error_message_prefix,
1086 $this->userinfo);
1087 }
1088 if ($this->mode & PEAR_ERROR_PRINT) {
1089 $modes[] = 'print';
1090 }
1091 if ($this->mode & PEAR_ERROR_TRIGGER) {
1092 $modes[] = 'trigger';
1093 }
1094 if ($this->mode & PEAR_ERROR_DIE) {
1095 $modes[] = 'die';
1096 }
1097 if ($this->mode & PEAR_ERROR_RETURN) {
1098 $modes[] = 'return';
1099 }
1100 return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
1101 'prefix="%s" info="%s"]',
1102 strtolower(get_class($this)), $this->message, $this->code,
1103 implode("|", $modes), $levels[$this->level],
1104 $this->error_message_prefix,
1105 $this->userinfo);
1106 }

References PEAR_ERROR_CALLBACK, PEAR_ERROR_DIE, PEAR_ERROR_PRINT, PEAR_ERROR_RETURN, and PEAR_ERROR_TRIGGER.

Field Documentation

◆ $backtrace

PEAR_Error::$backtrace = null

Definition at line 836 of file PEAR.php.

Referenced by getBacktrace().

◆ $code

PEAR_Error::$code = -1

Definition at line 833 of file PEAR.php.

Referenced by getCode(), ilBMFFault\getFault(), MDB2_Error\MDB2_Error(), and PEAR_Error().

◆ $error_message_prefix

PEAR_Error::$error_message_prefix = ''

Definition at line 830 of file PEAR.php.

Referenced by ilBMFFault\getActor(), and ilBMFFault\getFault().

◆ $level

PEAR_Error::$level = E_USER_NOTICE

Definition at line 832 of file PEAR.php.

Referenced by MDB2_Error\MDB2_Error().

◆ $message

PEAR_Error::$message = ''

Definition at line 834 of file PEAR.php.

Referenced by ilBMFFault\getFault(), and PEAR_Error().

◆ $mode

PEAR_Error::$mode = PEAR_ERROR_RETURN

Definition at line 831 of file PEAR.php.

Referenced by getMode(), ilBMFFault\ilBMFFault(), MDB2_Error\MDB2_Error(), and PEAR_Error().

◆ $userinfo

PEAR_Error::$userinfo = ''

Definition at line 835 of file PEAR.php.

Referenced by ilBMFFault\getDetail(), ilBMFFault\getFault(), getUserInfo(), and PEAR_Error().


The documentation for this class was generated from the following file: