From: Stig Bakken Date: Thu, 9 Jan 2003 15:14:23 +0000 (+0000) Subject: * added debug_backtrace() support to PEAR errors X-Git-Tag: PHP_5_0_dev_before_13561_fix~360 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f39c0ad2b6ef06c5e130c9eeef2d4775a3ca20b1;p=php * added debug_backtrace() support to PEAR errors --- diff --git a/pear/PEAR.php b/pear/PEAR.php index 7fa35a8495..7f034b7b0a 100644 --- a/pear/PEAR.php +++ b/pear/PEAR.php @@ -670,11 +670,7 @@ class PEAR_Error var $code = -1; var $message = ''; var $userinfo = ''; - - // Wait until we have a stack-groping function in PHP. - //var $file = ''; - //var $line = 0; - + var $backtrace = null; // }}} // {{{ constructor @@ -709,6 +705,9 @@ class PEAR_Error $this->code = $code; $this->mode = $mode; $this->userinfo = $userinfo; + if (function_exists("debug_backtrace")) { + $this->backtrace = debug_backtrace(); + } if ($mode & PEAR_ERROR_CALLBACK) { $this->level = E_USER_NOTICE; $this->callback = $options; @@ -853,6 +852,25 @@ class PEAR_Error return $this->getUserInfo(); } + // }}} + // {{{ getBacktrace() + + /** + * Get the call backtrace from where the error was generated. + * Supported with PHP 4.3.0 or newer. + * + * @param int $frame (optional) what frame to fetch + * @return array Backtrace, or NULL if not available. + * @access public + */ + function getBacktrace($frame = null) + { + if ($frame === null) { + return $this->backtrace; + } + return $this->backtrace[$frame]; + } + // }}} // {{{ addUserInfo()