cvs: php4 /pear PEAR.php
| From: | Stig Bakken | Date: | Thu, 09 Jan 2003 15:14:24 +0000 |
| Subject: | cvs: php4 /pear PEAR.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8144@lists.php.net to get a copy of this message | ||
ssb Thu Jan 9 10:14:24 2003 EDT
Modified files:
/php4/pear PEAR.php
Log:
* added debug_backtrace() support to PEAR errors
Index: php4/pear/PEAR.php
diff -u php4/pear/PEAR.php:1.51 php4/pear/PEAR.php:1.52
--- php4/pear/PEAR.php:1.51 Tue Dec 31 11:18:22 2002
+++ php4/pear/PEAR.php Thu Jan 9 10:14:23 2003
@@ -18,7 +18,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: PEAR.php,v 1.51 2002/12/31 16:18:22 sebastian Exp $
+// $Id: PEAR.php,v 1.52 2003/01/09 15:14:23 ssb Exp $
//
define('PEAR_ERROR_RETURN', 1);
@@ -670,11 +670,7 @@
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 @@
$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;
@@ -851,6 +850,25 @@
function getDebugInfo()
{
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];
}
// }}}