]> granicus.if.org Git - php/commitdiff
* PEAR_Error now supports exceptions when using Zend Engine 2. Set the
authorStig Bakken <ssb@php.net>
Tue, 21 Jan 2003 13:32:34 +0000 (13:32 +0000)
committerStig Bakken <ssb@php.net>
Tue, 21 Jan 2003 13:32:34 +0000 (13:32 +0000)
  error mode to PEAR_ERROR_EXCEPTION to make PEAR_Error throw itself
  as an exception (invoke PEAR errors with raiseError() or throwError()
  just like before).

pear/PEAR.php
pear/package-PEAR.xml

index 7f034b7b0a9952e535e92acc1409a54f0cbdaeda..0543be1ea33838000b3bc89684baf4a6fd77bb7e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 //
 // +----------------------------------------------------------------------+
-// | PHP Version 4                                                        |
+// | PEAR, the PHP Extension and Application Repository                   |
 // +----------------------------------------------------------------------+
 // | Copyright (c) 1997-2003 The PHP Group                                |
 // +----------------------------------------------------------------------+
 // $Id$
 //
 
-define('PEAR_ERROR_RETURN',   1);
-define('PEAR_ERROR_PRINT',    2);
-define('PEAR_ERROR_TRIGGER',  4);
-define('PEAR_ERROR_DIE',      8);
-define('PEAR_ERROR_CALLBACK', 16);
+define('PEAR_ERROR_RETURN',     1);
+define('PEAR_ERROR_PRINT',      2);
+define('PEAR_ERROR_TRIGGER',    4);
+define('PEAR_ERROR_DIE',        8);
+define('PEAR_ERROR_CALLBACK',  16);
+define('PEAR_ERROR_EXCEPTION', 32);
 define('PEAR_ZE2', (function_exists('version_compare') &&
                     version_compare(zend_version(), "2-dev", "ge")));
 
@@ -243,8 +244,8 @@ class PEAR
      *
      * @param int $mode
      *        One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
-     *        PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or
-     *        PEAR_ERROR_CALLBACK.
+     *        PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
+     *        PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
      *
      * @param mixed $options
      *        When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
@@ -268,6 +269,7 @@ class PEAR
      * @see PEAR_ERROR_TRIGGER
      * @see PEAR_ERROR_DIE
      * @see PEAR_ERROR_CALLBACK
+     * @see PEAR_ERROR_EXCEPTION
      *
      * @since PHP 4.0.5
      */
@@ -287,6 +289,7 @@ class PEAR
             case PEAR_ERROR_PRINT:
             case PEAR_ERROR_TRIGGER:
             case PEAR_ERROR_DIE:
+            case PEAR_ERROR_EXCEPTION:
             case null:
                 $setmode = $mode;
                 $setoptions = $options;
@@ -436,8 +439,8 @@ class PEAR
      *                  to define these if you want to use codes)
      *
      * @param int $mode      One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
-     *                  PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or
-     *                  PEAR_ERROR_CALLBACK.
+     *                  PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
+     *                  PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
      *
      * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
      *                  specifies the PHP-internal error level (one of
@@ -683,8 +686,8 @@ class PEAR_Error
      * @param int $code     (optional) error code
      *
      * @param int $mode     (optional) error mode, one of: PEAR_ERROR_RETURN,
-     * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER or
-     * PEAR_ERROR_CALLBACK
+     * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
+     * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
      *
      * @param mixed $options   (optional) error level, _OR_ in the case of
      * PEAR_ERROR_CALLBACK, the callback function or object/method
@@ -752,6 +755,9 @@ class PEAR_Error
                       @call_user_func($this->callback, $this);
             }
         }
+        if (PEAR_ZE2 && $this->mode & PEAR_ERROR_EXCEPTION) {
+            eval('throw $this;');
+        }
     }
 
     // }}}
index a3cdf6bb1a9f577345b66eb3058c4659cf472058..4965f302552cbb981f413dbc2af150fc364b65ae 100644 (file)
     </maintainer>
   </maintainers>
   <release>
-    <version>1.0.1</version>
+    <version>1.1-dev</version>
     <state>stable</state>
     <date>2003-01-10</date>
     <notes>
-* PEAR_Error class has call backtrace available by
-  calling getBacktrace().  Available if used with
-  PHP 4.3 or newer.
-
-* PEAR_Config class uses getenv() rather than $_ENV
-  to read environment variables.
-
-* System::which() Windows fix, now looks for
-  exe/bat/cmd/com suffixes rather than just exe
-
-* Added "pear cvsdiff" command
-
-* Windows output buffering bugfix for "pear" command
+* PEAR_Error now supports exceptions when using Zend Engine 2.  Set the
+  error mode to PEAR_ERROR_EXCEPTION to make PEAR_Error throw itself
+  as an exception (invoke PEAR errors with raiseError() or throwError()
+  just like before).
 </notes>
     <filelist>
       <file role="data" name="package.dtd"/>
     </deps>
   </release>
   <changelog>
+   <release>
+     <version>1.0.1</version>
+     <state>stable</state>
+     <date>2003-01-10</date>
+     <notes>
+ * PEAR_Error class has call backtrace available by
+   calling getBacktrace().  Available if used with
+   PHP 4.3 or newer.
+ * PEAR_Config class uses getenv() rather than $_ENV
+   to read environment variables.
+ * System::which() Windows fix, now looks for
+   exe/bat/cmd/com suffixes rather than just exe
+ * Added "pear cvsdiff" command
+ * Windows output buffering bugfix for "pear" command
+ </notes>
+     <deps>
+       <dep type="php" rel="ge" version="4.1"/>
+       <dep type="pkg" rel="ge" version="0.4">Archive_Tar</dep>
+       <dep type="pkg" rel="ge" version="0.11">Console_Getopt</dep>
+     </deps>
+   </release>
    <release>
      <version>1.0</version>
      <state>stable</state>