Bearsampp 2026.9.23
Loading...
Searching...
No Matches
PEAR_Error Class Reference

Public Member Functions

 __construct ($message='unknown error', $code=null, $mode=null, $options=null, $userinfo=null)
 __toString ()
 addUserInfo ($info)
 getBacktrace ($frame=null)
 getCallback ()
 getCode ()
 getDebugInfo ()
 getMessage ()
 getMode ()
 getType ()
 getUserInfo ()
 PEAR_Error ( $message='unknown error', $code=null, $mode=null, $options=null, $userinfo=null)
 toString ()

Data Fields

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

Detailed Description

Definition at line 863 of file PEAR.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $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 894 of file PEAR.php.

896 {
897 if ($mode === null) {
899 }
900 $this->message = $message;
901 $this->code = $code;
902 $this->mode = $mode;
903 $this->userinfo = $userinfo;
904
905 $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace');
906
907 if (!$skiptrace) {
908 $this->backtrace = debug_backtrace();
909 if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) {
910 unset($this->backtrace[0]['object']);
911 }
912 }
913
915 $this->level = E_USER_NOTICE;
916 $this->callback = $options;
917 } else {
918 if ($options === null) {
919 $options = E_USER_NOTICE;
920 }
921
922 $this->level = $options;
923 $this->callback = null;
924 }
925
926 if ($this->mode & PEAR_ERROR_PRINT) {
927 if (is_null($options) || is_int($options)) {
928 $format = "%s";
929 } else {
930 $format = $options;
931 }
932
933 printf($format, $this->getMessage());
934 }
935
936 if ($this->mode & PEAR_ERROR_TRIGGER) {
937 trigger_error($this->getMessage(), $this->level);
938 }
939
940 if ($this->mode & PEAR_ERROR_DIE) {
941 $msg = $this->getMessage();
942 if (is_null($options) || is_int($options)) {
943 $format = "%s";
944 if (substr($msg, -1) != "\n") {
945 $msg .= "\n";
946 }
947 } else {
948 $format = $options;
949 }
950 printf($format, $msg);
951 exit($code);
952 }
953
954 if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) {
955 call_user_func($this->callback, $this);
956 }
957
958 if ($this->mode & PEAR_ERROR_EXCEPTION) {
959 trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
960 eval('$e = new Exception($this->message, $this->code);throw($e);');
961 }
962 }
const PEAR_ERROR_PRINT
Definition PEAR.php:25
const PEAR_ERROR_TRIGGER
Definition PEAR.php:26
const PEAR_ERROR_RETURN
Definition PEAR.php:24
const PEAR_ERROR_EXCEPTION
Definition PEAR.php:33
const PEAR_ERROR_CALLBACK
Definition PEAR.php:28
const PEAR_ERROR_DIE
Definition PEAR.php:27
getMessage()
Definition PEAR.php:1010
static & getStaticProperty($class, $var)
Definition PEAR.php:261
$options
Definition pearcmd.php:145

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

Referenced by PEAR_Error().

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

Member Function Documentation

◆ __toString()

__toString ( )

Definition at line 1087 of file PEAR.php.

1088 {
1089 return $this->getMessage();
1090 }

References getMessage().

Here is the call graph for this function:

◆ addUserInfo()

addUserInfo ( $info)

Definition at line 1078 of file PEAR.php.

1079 {
1080 if (empty($this->userinfo)) {
1081 $this->userinfo = $info;
1082 } else {
1083 $this->userinfo .= " ** $info";
1084 }
1085 }

◆ getBacktrace()

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 1067 of file PEAR.php.

1068 {
1069 if (defined('PEAR_IGNORE_BACKTRACE')) {
1070 return null;
1071 }
1072 if ($frame === null) {
1073 return $this->backtrace;
1074 }
1075 return $this->backtrace[$frame];
1076 }

References $backtrace.

◆ getCallback()

getCallback ( )

Get the callback function/method from an error object.

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

Definition at line 999 of file PEAR.php.

1000 {
1001 return $this->callback;
1002 }

References $callback.

◆ getCode()

getCode ( )

Get error code from an error object

Returns
int error code @access public

Definition at line 1021 of file PEAR.php.

1022 {
1023 return $this->code;
1024 }

References $code.

◆ getDebugInfo()

getDebugInfo ( )

Get additional debug information supplied by the application.

Returns
string debug information @access public

Definition at line 1054 of file PEAR.php.

1055 {
1056 return $this->getUserInfo();
1057 }
getUserInfo()
Definition PEAR.php:1043

References getUserInfo().

Here is the call graph for this function:

◆ getMessage()

getMessage ( )

Get the error message from an error object.

Returns
string full error message @access public

Definition at line 1010 of file PEAR.php.

1011 {
1012 return ($this->error_message_prefix . $this->message);
1013 }

Referenced by __construct(), and __toString().

Here is the caller graph for this function:

◆ getMode()

getMode ( )

Get the error mode from an error object.

Returns
int error mode @access public

Definition at line 988 of file PEAR.php.

989 {
990 return $this->mode;
991 }

References $mode.

◆ getType()

getType ( )

Get the name of this error/exception.

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

Definition at line 1032 of file PEAR.php.

1033 {
1034 return get_class($this);
1035 }

◆ getUserInfo()

getUserInfo ( )

Get additional user-supplied information.

Returns
string user-supplied information @access public

Definition at line 1043 of file PEAR.php.

1044 {
1045 return $this->userinfo;
1046 }

References $userinfo.

Referenced by getDebugInfo().

Here is the caller graph for this function:

◆ PEAR_Error()

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

Only here for backwards compatibility.

Class "Cache_Error" still uses it, among others.

Parameters
string$messageMessage
int$codeError code
int$modeError mode
mixed$optionsSee __construct()
string$userinfoAdditional user/debug info

Definition at line 975 of file PEAR.php.

978 {
980 }
__construct($message='unknown error', $code=null, $mode=null, $options=null, $userinfo=null)
Definition PEAR.php:894

References $code, $message, $mode, $options, $userinfo, and __construct().

Here is the call graph for this function:

◆ toString()

toString ( )

Make a string representation of this object.

Returns
string a string with an object summary @access public

Definition at line 1098 of file PEAR.php.

1099 {
1100 $modes = array();
1101 $levels = array(E_USER_NOTICE => 'notice',
1102 E_USER_WARNING => 'warning',
1103 E_USER_ERROR => 'error');
1104 if ($this->mode & PEAR_ERROR_CALLBACK) {
1105 if (is_array($this->callback)) {
1106 $callback = (is_object($this->callback[0]) ?
1107 strtolower(get_class($this->callback[0])) :
1108 $this->callback[0]) . '::' .
1109 $this->callback[1];
1110 } else {
1112 }
1113 return sprintf('[%s: message="%s" code=%d mode=callback '.
1114 'callback=%s prefix="%s" info="%s"]',
1115 strtolower(get_class($this)), $this->message, $this->code,
1116 $callback, $this->error_message_prefix,
1117 $this->userinfo);
1118 }
1119 if ($this->mode & PEAR_ERROR_PRINT) {
1120 $modes[] = 'print';
1121 }
1122 if ($this->mode & PEAR_ERROR_TRIGGER) {
1123 $modes[] = 'trigger';
1124 }
1125 if ($this->mode & PEAR_ERROR_DIE) {
1126 $modes[] = 'die';
1127 }
1128 if ($this->mode & PEAR_ERROR_RETURN) {
1129 $modes[] = 'return';
1130 }
1131 return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
1132 'prefix="%s" info="%s"]',
1133 strtolower(get_class($this)), $this->message, $this->code,
1134 implode("|", $modes), $levels[$this->level],
1135 $this->error_message_prefix,
1136 $this->userinfo);
1137 }
if(!extension_loaded('winbinder')) if(!dl('php_winbinder.dll')) trigger_error("WinBinder extension could not be loaded.\n" E_USER_ERROR
Definition winbinder.php:14

References $callback, E_USER_ERROR, PEAR_ERROR_CALLBACK, PEAR_ERROR_DIE, PEAR_ERROR_PRINT, PEAR_ERROR_RETURN, and PEAR_ERROR_TRIGGER.

Field Documentation

◆ $backtrace

$backtrace = null

Definition at line 871 of file PEAR.php.

Referenced by getBacktrace().

◆ $callback

$callback = null

Definition at line 872 of file PEAR.php.

Referenced by getCallback(), and toString().

◆ $code

$code = -1

Definition at line 868 of file PEAR.php.

Referenced by __construct(), getCode(), and PEAR_Error().

◆ $error_message_prefix

$error_message_prefix = ''

Definition at line 865 of file PEAR.php.

◆ $level

$level = E_USER_NOTICE

Definition at line 867 of file PEAR.php.

◆ $message

$message = ''

Definition at line 869 of file PEAR.php.

Referenced by __construct(), and PEAR_Error().

◆ $mode

Definition at line 866 of file PEAR.php.

Referenced by __construct(), getMode(), and PEAR_Error().

◆ $userinfo

$userinfo = ''

Definition at line 870 of file PEAR.php.

Referenced by __construct(), getUserInfo(), and PEAR_Error().


The documentation for this class was generated from the following file:
  • E:/Bearsampp-development/sandbox/core/libs/php/pear/pear/PEAR.php