Allow to provide additional details with exceptions. For now include PEAR_Error's...
authorJan Schneider <jan@horde.org>
Mon, 13 Dec 2010 17:43:51 +0000 (18:43 +0100)
committerJan Schneider <jan@horde.org>
Thu, 16 Dec 2010 10:23:54 +0000 (11:23 +0100)
framework/Exception/lib/Horde/Exception.php
framework/Exception/lib/Horde/Exception/Pear.php
framework/Exception/lib/Horde/Exception/Prior.php

index 84f5cfe..790acb5 100644 (file)
@@ -16,10 +16,17 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
      */
     class Horde_Exception extends Exception
     {
-
         private $_previous = null;
 
         /**
+         * Error details that should not be part of the main exception message,
+         * e.g. any additional debugging information.
+         *
+         * @var string
+         */
+        public $details;
+
+        /**
          * Construct the exception
          *
          * @param string $msg
@@ -71,5 +78,12 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
      */
     class Horde_Exception extends Exception
     {
+        /**
+         * Error details that should not be part of the main exception message,
+         * e.g. any additional debugging information.
+         *
+         * @var string
+         */
+        public $details;
     }
 }
index 0f9d76c..d26feeb 100644 (file)
@@ -37,6 +37,9 @@ class Horde_Exception_Pear extends Horde_Exception
             $error->getMessage() . $this->_getPearTrace($error),
             $error->getCode()
         );
+        if ($details = $error->getUserInfo()) {
+            $this->details = $details;
+        }
     }
 
     /**
index a71d948..e9dfc1b 100644 (file)
@@ -32,6 +32,10 @@ class Horde_Exception_Prior extends Horde_Exception
             if ($message instanceof Exception) {
                 $previous = $message;
             }
+            if (method_exists($message, 'getUserinfo') &&
+                $details = $message->getUserinfo()) {
+                $this->details = $details;
+            }
             $message = $message->getMessage();
         }