ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PEAR_Error Class Reference
+ Collaboration diagram for PEAR_Error:

Public Member Functions

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

Constructor & Destructor Documentation

◆ __construct()

PEAR_Error::__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

public

Definition at line 865 of file PEAR.php.

References $code, $format, $message, PHPMailer\PHPMailer\$options, PEAR\getStaticProperty(), PEAR_ERROR_CALLBACK, PEAR_ERROR_DIE, PEAR_ERROR_EXCEPTION, PEAR_ERROR_PRINT, PEAR_ERROR_RETURN, and PEAR_ERROR_TRIGGER.

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

Member Function Documentation

◆ __toString()

PEAR_Error::__toString ( )

Definition at line 1059 of file PEAR.php.

1060  {
1061  return $this->getMessage();
1062  }
getMessage()
Get the error message from an error object.
Definition: PEAR.php:961

◆ addUserInfo()

PEAR_Error::addUserInfo (   $info)

Definition at line 1048 of file PEAR.php.

References $info.

1049  {
1050  if (empty($this->userinfo)) {
1051  $this->userinfo = $info;
1052  } else {
1053  $this->userinfo .= " ** $info";
1054  }
1055  }
$info
Definition: index.php:5

◆ 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. public

Definition at line 1034 of file PEAR.php.

1035  {
1036  if (defined('PEAR_IGNORE_BACKTRACE')) {
1037  return null;
1038  }
1039  if ($frame === null) {
1040  return $this->backtrace;
1041  }
1042  return $this->backtrace[$frame];
1043  }
$backtrace
Definition: PEAR.php:840

◆ getCallback()

PEAR_Error::getCallback ( )

Get the callback function/method from an error object.

Returns
mixed callback function or object/method array public

Definition at line 947 of file PEAR.php.

947  {
948  return $this->callback;
949  }

◆ getCode()

PEAR_Error::getCode ( )

Get error code from an error object.

Returns
int error code public

Definition at line 976 of file PEAR.php.

References $code.

977  {
978  return $this->code;
979  }

◆ getDebugInfo()

PEAR_Error::getDebugInfo ( )

Get additional debug information supplied by the application.

Returns
string debug information public

Definition at line 1018 of file PEAR.php.

1019  {
1020  return $this->getUserInfo();
1021  }
getUserInfo()
Get additional user-supplied information.
Definition: PEAR.php:1004

◆ getMessage()

PEAR_Error::getMessage ( )

Get the error message from an error object.

Returns
string full error message public

Definition at line 961 of file PEAR.php.

962  {
963  return ($this->error_message_prefix . $this->message);
964  }

◆ getMode()

PEAR_Error::getMode ( )

Get the error mode from an error object.

Returns
int error mode public

Definition at line 934 of file PEAR.php.

934  {
935  return $this->mode;
936  }

◆ getType()

PEAR_Error::getType ( )

Get the name of this error/exception.

Returns
string error/exception name (type) public

Definition at line 990 of file PEAR.php.

991  {
992  return get_class($this);
993  }

◆ getUserInfo()

PEAR_Error::getUserInfo ( )

Get additional user-supplied information.

Returns
string user-supplied information public

Definition at line 1004 of file PEAR.php.

1005  {
1006  return $this->userinfo;
1007  }

◆ toString()

PEAR_Error::toString ( )

Make a string representation of this object.

Returns
string a string with an object summary public

Definition at line 1072 of file PEAR.php.

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

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

Field Documentation

◆ $backtrace

PEAR_Error::$backtrace = null

Definition at line 840 of file PEAR.php.

◆ $code

PEAR_Error::$code = -1

Definition at line 837 of file PEAR.php.

◆ $error_message_prefix

PEAR_Error::$error_message_prefix = ''

Definition at line 834 of file PEAR.php.

◆ $level

PEAR_Error::$level = E_USER_NOTICE

Definition at line 836 of file PEAR.php.

◆ $message

PEAR_Error::$message = ''

Definition at line 838 of file PEAR.php.

◆ $mode

PEAR_Error::$mode = PEAR_ERROR_RETURN

Definition at line 835 of file PEAR.php.

◆ $userinfo

PEAR_Error::$userinfo = ''

Definition at line 839 of file PEAR.php.


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