2
0
Переглянути джерело

ZF-8547: Merge Zend_Exception previous exception support to trunk

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19661 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 роки тому
батько
коміт
3690d0e698
82 змінених файлів з 575 додано та 224 видалено
  1. 2 0
      documentation/manual/en/manual.xml.in
  2. 37 0
      documentation/manual/en/module_specs/Zend_Exception-Basic.xml
  3. 45 0
      documentation/manual/en/module_specs/Zend_Exception-Previous.xml
  4. 6 5
      documentation/manual/en/module_specs/Zend_Exception.xml
  5. 4 4
      library/Zend/Acl.php
  6. 3 3
      library/Zend/Acl/Role/Registry.php
  7. 1 1
      library/Zend/Amf/Parse/Amf3/Serializer.php
  8. 2 2
      library/Zend/Amf/Parse/TypeLoader.php
  9. 2 2
      library/Zend/Amf/Request.php
  10. 3 3
      library/Zend/Amf/Server.php
  11. 1 1
      library/Zend/Auth/Adapter/DbTable.php
  12. 2 2
      library/Zend/Cache.php
  13. 1 1
      library/Zend/Cache/Backend.php
  14. 1 1
      library/Zend/Controller/Action/HelperBroker.php
  15. 2 1
      library/Zend/Controller/Dispatcher/Standard.php
  16. 8 5
      library/Zend/Controller/Front.php
  17. 12 6
      library/Zend/Controller/Plugin/Broker.php
  18. 2 2
      library/Zend/Currency.php
  19. 3 3
      library/Zend/Db/Adapter/Db2/Exception.php
  20. 6 7
      library/Zend/Db/Adapter/Exception.php
  21. 2 2
      library/Zend/Db/Adapter/Pdo/Abstract.php
  22. 2 2
      library/Zend/Db/Adapter/Pdo/Ibm.php
  23. 2 19
      library/Zend/Db/Statement/Exception.php
  24. 2 2
      library/Zend/Db/Table/Row/Abstract.php
  25. 1 1
      library/Zend/Db/Table/Rowset/Abstract.php
  26. 62 9
      library/Zend/Exception.php
  27. 2 1
      library/Zend/Feed/Reader/Entry/Rss.php
  28. 2 1
      library/Zend/Feed/Reader/Feed/Rss.php
  29. 1 1
      library/Zend/Filter/Compress/Tar.php
  30. 1 1
      library/Zend/Http/Client.php
  31. 1 1
      library/Zend/Json/Server.php
  32. 2 2
      library/Zend/Mail/Storage/Folder/Maildir.php
  33. 2 2
      library/Zend/Mail/Storage/Folder/Mbox.php
  34. 1 1
      library/Zend/Mail/Storage/Imap.php
  35. 1 1
      library/Zend/Mail/Storage/Writable/Maildir.php
  36. 1 1
      library/Zend/Measure/Abstract.php
  37. 1 1
      library/Zend/Measure/Number.php
  38. 4 3
      library/Zend/Pdf/FileParser/Font/OpenType.php
  39. 3 3
      library/Zend/Pdf/Font.php
  40. 2 2
      library/Zend/Pdf/Page.php
  41. 1 1
      library/Zend/Pdf/Trailer/Keeper.php
  42. 5 5
      library/Zend/Queue/Adapter/Db.php
  43. 1 1
      library/Zend/Rest/Server.php
  44. 5 5
      library/Zend/Search/Lucene.php
  45. 2 2
      library/Zend/Search/Lucene/Index/SegmentInfo.php
  46. 4 3
      library/Zend/Search/Lucene/Index/Writer.php
  47. 5 3
      library/Zend/Search/Lucene/Search/QueryParser.php
  48. 1 1
      library/Zend/Search/Lucene/Search/QueryParserContext.php
  49. 1 1
      library/Zend/Service/Amazon/Ec2/Abstract.php
  50. 3 3
      library/Zend/Service/SlideShare.php
  51. 1 1
      library/Zend/Service/StrikeIron.php
  52. 1 1
      library/Zend/Service/StrikeIron/Base.php
  53. 1 1
      library/Zend/Service/Technorati/Utils.php
  54. 4 4
      library/Zend/Translate/Adapter.php
  55. 33 12
      library/Zend/View/Abstract.php
  56. 2 2
      library/Zend/View/Exception.php
  57. 6 2
      library/Zend/View/Helper/Action.php
  58. 3 1
      library/Zend/View/Helper/Doctype.php
  59. 4 2
      library/Zend/View/Helper/FormElement.php
  60. 18 6
      library/Zend/View/Helper/HeadLink.php
  61. 24 8
      library/Zend/View/Helper/HeadMeta.php
  62. 21 7
      library/Zend/View/Helper/HeadScript.php
  63. 18 6
      library/Zend/View/Helper/HeadStyle.php
  64. 3 1
      library/Zend/View/Helper/HeadTitle.php
  65. 3 1
      library/Zend/View/Helper/HtmlList.php
  66. 3 1
      library/Zend/View/Helper/Navigation.php
  67. 12 6
      library/Zend/View/Helper/Navigation/Breadcrumbs.php
  68. 9 5
      library/Zend/View/Helper/Navigation/HelperAbstract.php
  69. 6 2
      library/Zend/View/Helper/Navigation/Links.php
  70. 12 6
      library/Zend/View/Helper/Navigation/Menu.php
  71. 9 3
      library/Zend/View/Helper/Navigation/Sitemap.php
  72. 10 6
      library/Zend/View/Helper/PaginationControl.php
  73. 3 1
      library/Zend/View/Helper/Partial.php
  74. 3 1
      library/Zend/View/Helper/PartialLoop.php
  75. 3 1
      library/Zend/View/Helper/Placeholder/Container/Abstract.php
  76. 3 1
      library/Zend/View/Helper/Placeholder/Container/Standalone.php
  77. 3 1
      library/Zend/View/Helper/Placeholder/Registry.php
  78. 9 3
      library/Zend/View/Helper/Translate.php
  79. 1 1
      library/Zend/XmlRpc/Fault.php
  80. 1 1
      library/Zend/XmlRpc/Value.php
  81. 2 0
      tests/Zend/AllTests.php
  82. 78 0
      tests/Zend/ExceptionTest.php

+ 2 - 0
documentation/manual/en/manual.xml.in

@@ -180,6 +180,8 @@
     <chapter id="zend.exception">
         <title>Zend_Exception</title>
         <xi:include href="module_specs/Zend_Exception.xml" />
+        <xi:include href="module_specs/Zend_Exception-Basic.xml" />
+        <xi:include href="module_specs/Zend_Exception-Previous.xml" />
     </chapter>
 
     <chapter id="zend.feed">

+ 37 - 0
documentation/manual/en/module_specs/Zend_Exception-Basic.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Reviewed: no -->
+<sect1 id="zend.exception.basic">
+    <title>Basic usage</title>
+
+    <para>
+        <classname>Zend_Exception</classname> is the base class for all exceptions thrown by Zend
+        Framework.  This class extends the base <classname>Exception</classname> class of PHP.
+    </para>
+
+    <example id="zend.exception.catchall.example">
+        <title>Catch all Zend Framework exceptions</title>
+
+        <programlisting language="php"><![CDATA[
+try {
+    // your code
+} catch (Zend_Exception $e) {
+    // do something
+}
+]]></programlisting>
+    </example>
+
+    <example id="zend.exception.catchcomponent.example">
+        <title>Catch exceptions thrown by a specific component of Zend Framework</title>
+
+        <programlisting language="php"><![CDATA[
+try {
+    // your code
+} catch (Zend_Db_Exception $e) {
+    // do something
+}
+]]></programlisting>
+    </example>
+</sect1>
+<!--
+vim:se ts=4 sw=4 et:
+-->

+ 45 - 0
documentation/manual/en/module_specs/Zend_Exception-Previous.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Reviewed: no -->
+<sect1 id="zend.exception.previous">
+    <title>Previous Exceptions</title>
+
+    <para>
+        Since Zend Framework 1.10, <classname>Zend_Exception</classname> implements the PHP 5.3
+        support for previous exceptions. Simply put, when in a <methodname>catch</methodname>
+        block, you can throw a new exception that references the original exception, which helps
+        provide additional context when debugging. By providing this support in Zend Framework, your
+        code may now be forwards compatible with PHP 5.3.
+    </para>
+
+    <para>
+        Previous exceptions are indicated as the third argument to an exception constructor.
+    </para>
+
+    <example id="zend.exception.previous.example">
+        <title>Previous exceptions</title>
+
+        <programlisting language="php"><![CDATA[
+try {
+    $db->query($sql);
+} catch (Zend_Db_Statement_Exception $e) {
+    if ($e->getPrevious()) {
+        echo '[' . get_class($e) 
+            . '] has the previous exception of [' 
+            . get_class($e->getPrevious()) 
+            . ']' . PHP_EOL;
+    } else {
+        echo '[' . get_class($e) 
+            . '] does not have a previous exception' 
+            . PHP_EOL;
+    }
+
+    echo $e; 
+    // displays all exceptions starting by the first thrown 
+    // exception if available.
+}
+]]></programlisting>
+    </example>
+</sect1>
+<!--
+vim:se ts=4 sw=4 et:
+-->

+ 6 - 5
documentation/manual/en/module_specs/Zend_Exception.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- Reviewed: no -->
 <sect1 id="zend.exception.using">
-
     <title>Using Exceptions</title>
 
     <para>
@@ -11,14 +10,16 @@
 
     <example id="zend.exception.using.example">
         <title>Catching an Exception</title>
+
         <para>
             The following code listing demonstrates how to catch an exception thrown in a Zend
             Framework class:
         </para>
+
         <programlisting language="php"><![CDATA[
 try {
     // Calling Zend_Loader::loadClass() with a non-existant class will cause
-    // an exception to be thrown in Zend_Loader
+    // an exception to be thrown in Zend_Loader:
     Zend_Loader::loadClass('nonexistantclass');
 } catch (Zend_Exception $e) {
     echo "Caught exception: " . get_class($e) . "\n";
@@ -27,6 +28,7 @@ try {
 }
 ]]></programlisting>
     </example>
+
     <para>
         <classname>Zend_Exception</classname> can be used as a catch-all exception class in a
         catch block to trap all exceptions thrown by Zend Framework classes. This can
@@ -37,10 +39,9 @@ try {
         The documentation for each Zend Framework
         component and class will contain specific information on which methods
         throw exceptions, the circumstances that cause an exception to be thrown,
-        and the class of all exceptions that may be thrown.
+        and the various exception types that may be thrown.
     </para>
-
 </sect1>
 <!--
 vim:se ts=4 sw=4 et:
--->
+-->

+ 4 - 4
library/Zend/Acl.php

@@ -309,7 +309,7 @@ class Zend_Acl
                 }
                 $resourceParent = $this->get($resourceParentId);
             } catch (Zend_Acl_Exception $e) {
-                throw new Zend_Acl_Exception("Parent Resource id '$resourceParentId' does not exist");
+                throw new Zend_Acl_Exception("Parent Resource id '$resourceParentId' does not exist", 0, $e);
             }
             $this->_resources[$resourceParentId]['children'][$resourceId] = $resource;
         }
@@ -407,7 +407,7 @@ class Zend_Acl
             $resourceId     = $this->get($resource)->getResourceId();
             $inheritId = $this->get($inherit)->getResourceId();
         } catch (Zend_Acl_Exception $e) {
-            throw $e;
+            throw new Zend_Acl_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         if (null !== $this->_resources[$resourceId]['parent']) {
@@ -445,7 +445,7 @@ class Zend_Acl
         try {
             $resourceId = $this->get($resource)->getResourceId();
         } catch (Zend_Acl_Exception $e) {
-            throw $e;
+            throw new Zend_Acl_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         $resourcesRemoved = array($resourceId);
@@ -1161,4 +1161,4 @@ class Zend_Acl
     }
     
 }
-    
+    

+ 3 - 3
library/Zend/Acl/Role/Registry.php

@@ -91,7 +91,7 @@ class Zend_Acl_Role_Registry
                     }
                     $roleParent = $this->get($roleParentId);
                 } catch (Zend_Acl_Role_Registry_Exception $e) {
-                    throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist");
+                    throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist", 0, $e);
                 }
                 $roleParents[$roleParentId] = $roleParent;
                 $this->_roles[$roleParentId]['children'][$roleId] = $role;
@@ -200,7 +200,7 @@ class Zend_Acl_Role_Registry
             $roleId     = $this->get($role)->getRoleId();
             $inheritId = $this->get($inherit)->getRoleId();
         } catch (Zend_Acl_Role_Registry_Exception $e) {
-            throw $e;
+            throw new Zend_Acl_Role_Registry_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         $inherits = isset($this->_roles[$roleId]['parents'][$inheritId]);
@@ -236,7 +236,7 @@ class Zend_Acl_Role_Registry
         try {
             $roleId = $this->get($role)->getRoleId();
         } catch (Zend_Acl_Role_Registry_Exception $e) {
-            throw $e;
+            throw new Zend_Acl_Role_Registry_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         foreach ($this->_roles[$roleId]['children'] as $childId => $child) {

+ 1 - 1
library/Zend/Amf/Parse/Amf3/Serializer.php

@@ -496,7 +496,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
             }
         } catch (Exception $e) {
             require_once 'Zend/Amf/Exception.php';
-            throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage());
+            throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage(), 0, $e);
         }
 
         return $this;

+ 2 - 2
library/Zend/Amf/Parse/TypeLoader.php

@@ -222,10 +222,10 @@ final class Zend_Amf_Parse_TypeLoader
             }
             return $resource;
         } catch(Zend_Amf_Exception $e) {
-            throw $e;
+            throw new Zend_Amf_Exception($e->getMessage(), $e->getCode(), $e);
         } catch(Exception $e) {
             require_once 'Zend/Amf/Exception.php';
-            throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
+            throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource), 0, $e);
         }
     }
 }

+ 2 - 2
library/Zend/Amf/Request.php

@@ -151,7 +151,7 @@ class Zend_Amf_Request
             $data = $this->_deserializer->readTypeMarker();
         } catch (Exception $e) {
             require_once 'Zend/Amf/Exception.php';
-            throw new Zend_Amf_Exception('Unable to parse ' . $name . ' header data: ' . $e->getMessage() . ' '. $e->getLine());
+            throw new Zend_Amf_Exception('Unable to parse ' . $name . ' header data: ' . $e->getMessage() . ' '. $e->getLine(), 0, $e);
         }
 
         $header = new Zend_Amf_Value_MessageHeader($name, $mustRead, $data, $length);
@@ -173,7 +173,7 @@ class Zend_Amf_Request
             $data = $this->_deserializer->readTypeMarker();
         } catch (Exception $e) {
             require_once 'Zend/Amf/Exception.php';
-            throw new Zend_Amf_Exception('Unable to parse ' . $targetURI . ' body data ' . $e->getMessage());
+            throw new Zend_Amf_Exception('Unable to parse ' . $targetURI . ' body data ' . $e->getMessage(), 0, $e);
         }
 
         // Check for AMF3 objectEncoding

+ 3 - 3
library/Zend/Amf/Server.php

@@ -314,7 +314,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
                     $this->getLoader()->load($className);
                 } catch (Exception $e) {
                     require_once 'Zend/Amf/Server/Exception.php';
-                    throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist: '.$e->getMessage());
+                    throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist: '.$e->getMessage(), 0, $e);
                 }
                 // Add the new loaded class to the server.
                 $this->setClass($className, $source);
@@ -350,7 +350,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
                     $object = $info->getDeclaringClass()->newInstance();
                 } catch (Exception $e) {
                     require_once 'Zend/Amf/Server/Exception.php';
-                    throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName() . ': '.$e->getMessage(), 621);
+                    throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName() . ': '.$e->getMessage(), 621, $e);
                 }
                 $this->_checkAcl($object, $info->getName());
                 $return = $info->invokeArgs($object, $params);
@@ -628,7 +628,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
         } catch (Exception $e) {
             // Handle any errors in the serialization and service  calls.
             require_once 'Zend/Amf/Server/Exception.php';
-            throw new Zend_Amf_Server_Exception('Handle error: ' . $e->getMessage() . ' ' . $e->getLine());
+            throw new Zend_Amf_Server_Exception('Handle error: ' . $e->getMessage() . ' ' . $e->getLine(), 0, $e);
         }
 
         // Return the Amf serialized output string

+ 1 - 1
library/Zend/Auth/Adapter/DbTable.php

@@ -415,7 +415,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
             require_once 'Zend/Auth/Adapter/Exception.php';
             throw new Zend_Auth_Adapter_Exception('The supplied parameters to Zend_Auth_Adapter_DbTable failed to '
                                                 . 'produce a valid sql statement, please check table and column names '
-                                                . 'for validity.');
+                                                . 'for validity.', 0, $e);
         }
         return $resultIdentities;
     }

+ 2 - 2
library/Zend/Cache.php

@@ -201,11 +201,11 @@ abstract class Zend_Cache
      * @param  string $msg  Message for the exception
      * @throws Zend_Cache_Exception
      */
-    public static function throwException($msg)
+    public static function throwException($msg, Exception $e = null)
     {
         // For perfs reasons, we use this dynamic inclusion
         require_once 'Zend/Cache/Exception.php';
-        throw new Zend_Cache_Exception($msg);
+        throw new Zend_Cache_Exception($msg, 0, $e);
     }
 
     /**

+ 1 - 1
library/Zend/Cache/Backend.php

@@ -232,7 +232,7 @@ class Zend_Cache_Backend
              */
             require_once 'Zend/Log.php';
         } catch (Zend_Exception $e) {
-            Zend_Cache::throwException('Logging feature is enabled but the Zend_Log class is not available');
+            Zend_Cache::throwException('Logging feature is enabled but the Zend_Log class is not available', $e);
         }
         if (isset($this->_directives['logger'])) {
             if ($this->_directives['logger'] instanceof Zend_Log) {

+ 1 - 1
library/Zend/Controller/Action/HelperBroker.php

@@ -366,7 +366,7 @@ class Zend_Controller_Action_HelperBroker
             $class = self::getPluginLoader()->load($name);
         } catch (Zend_Loader_PluginLoader_Exception $e) {
             require_once 'Zend/Controller/Action/Exception.php';
-            throw new Zend_Controller_Action_Exception('Action Helper by name ' . $name . ' not found');
+            throw new Zend_Controller_Action_Exception('Action Helper by name ' . $name . ' not found', 0, $e);
         }
 
         $helper = new $class();

+ 2 - 1
library/Zend/Controller/Dispatcher/Standard.php

@@ -297,7 +297,8 @@ class Zend_Controller_Dispatcher_Standard extends Zend_Controller_Dispatcher_Abs
                 } while ($curObLevel > $obLevel);
             }
 
-            throw $e;
+            require_once 'Zend/Controller/Exception.php';
+            throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         if (empty($disableOb)) {

+ 8 - 5
library/Zend/Controller/Front.php

@@ -287,9 +287,9 @@ class Zend_Controller_Front
     {
         try{
             $dir = new DirectoryIterator($path);
-        }catch(Exception $e){
+        } catch(Exception $e) {
             require_once 'Zend/Controller/Exception.php';
-            throw new Zend_Controller_Exception("Directory $path not readable");
+            throw new Zend_Controller_Exception("Directory $path not readable", 0, $e);
         }
         foreach ($dir as $file) {
             if ($file->isDot() || !$file->isDir()) {
@@ -946,7 +946,8 @@ class Zend_Controller_Front
                     $dispatcher->dispatch($this->_request, $this->_response);
                 } catch (Exception $e) {
                     if ($this->throwExceptions()) {
-                        throw $e;
+                        require_once 'Zend/Controller/Exception.php';
+                        throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
                     }
                     $this->_response->setException($e);
                 }
@@ -958,7 +959,8 @@ class Zend_Controller_Front
             } while (!$this->_request->isDispatched());
         } catch (Exception $e) {
             if ($this->throwExceptions()) {
-                throw $e;
+                require_once 'Zend/Controller/Exception.php';
+                throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
             }
 
             $this->_response->setException($e);
@@ -971,7 +973,8 @@ class Zend_Controller_Front
             $this->_plugins->dispatchLoopShutdown();
         } catch (Exception $e) {
             if ($this->throwExceptions()) {
-                throw $e;
+                require_once 'Zend/Controller/Exception.php';
+                throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
             }
 
             $this->_response->setException($e);

+ 12 - 6
library/Zend/Controller/Plugin/Broker.php

@@ -237,7 +237,8 @@ class Zend_Controller_Plugin_Broker extends Zend_Controller_Plugin_Abstract
                 $plugin->routeStartup($request);
             } catch (Exception $e) {
                 if (Zend_Controller_Front::getInstance()->throwExceptions()) {
-                    throw $e;
+                    require_once 'Zend/Controller/Exception.php';
+                    throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
                 } else {
                     $this->getResponse()->setException($e);
                 }
@@ -260,7 +261,8 @@ class Zend_Controller_Plugin_Broker extends Zend_Controller_Plugin_Abstract
                 $plugin->routeShutdown($request);
             } catch (Exception $e) {
                 if (Zend_Controller_Front::getInstance()->throwExceptions()) {
-                    throw $e;
+                    require_once 'Zend/Controller/Exception.php';
+                    throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
                 } else {
                     $this->getResponse()->setException($e);
                 }
@@ -287,7 +289,8 @@ class Zend_Controller_Plugin_Broker extends Zend_Controller_Plugin_Abstract
                 $plugin->dispatchLoopStartup($request);
             } catch (Exception $e) {
                 if (Zend_Controller_Front::getInstance()->throwExceptions()) {
-                    throw $e;
+                    require_once 'Zend/Controller/Exception.php';
+                    throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
                 } else {
                     $this->getResponse()->setException($e);
                 }
@@ -309,7 +312,8 @@ class Zend_Controller_Plugin_Broker extends Zend_Controller_Plugin_Abstract
                 $plugin->preDispatch($request);
             } catch (Exception $e) {
                 if (Zend_Controller_Front::getInstance()->throwExceptions()) {
-                    throw $e;
+                    require_once 'Zend/Controller/Exception.php';
+                    throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
                 } else {
                     $this->getResponse()->setException($e);
                 }
@@ -331,7 +335,8 @@ class Zend_Controller_Plugin_Broker extends Zend_Controller_Plugin_Abstract
                 $plugin->postDispatch($request);
             } catch (Exception $e) {
                 if (Zend_Controller_Front::getInstance()->throwExceptions()) {
-                    throw $e;
+                    require_once 'Zend/Controller/Exception.php';
+                    throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
                 } else {
                     $this->getResponse()->setException($e);
                 }
@@ -353,7 +358,8 @@ class Zend_Controller_Plugin_Broker extends Zend_Controller_Plugin_Abstract
                 $plugin->dispatchLoopShutdown();
             } catch (Exception $e) {
                 if (Zend_Controller_Front::getInstance()->throwExceptions()) {
-                    throw $e;
+                    require_once 'Zend/Controller/Exception.php';
+                    throw new Zend_Controller_Exception($e->getMessage(), $e->getCode(), $e);
                 } else {
                     $this->getResponse()->setException($e);
                 }

+ 2 - 2
library/Zend/Currency.php

@@ -516,7 +516,7 @@ class Zend_Currency
             $this->_options['locale'] = Zend_Locale::findLocale($locale);
         } catch (Zend_Locale_Exception $e) {
             require_once 'Zend/Currency/Exception.php';
-            throw new Zend_Currency_Exception($e->getMessage());
+            throw new Zend_Currency_Exception($e->getMessage(), 0, $e);
         }
 
         // Get currency details
@@ -605,7 +605,7 @@ class Zend_Currency
                         Zend_Locale_Format::convertNumerals(0, $options['script']);
                     } catch (Zend_Locale_Exception $e) {
                         require_once 'Zend/Currency/Exception.php';
-                        throw new Zend_Currency_Exception($e->getMessage());
+                        throw new Zend_Currency_Exception($e->getMessage(), 0, $e);
                     }
                     break;
 

+ 3 - 3
library/Zend/Db/Adapter/Db2/Exception.php

@@ -38,8 +38,8 @@ class Zend_Db_Adapter_Db2_Exception extends Zend_Db_Adapter_Exception
    protected $code = '00000';
    protected $message = 'unknown exception';
 
-   function __construct($msg = 'unknown exception', $state = '00000') {
-       $this->message = $msg;
-       $this->code = $state;
+   function __construct($message = 'unknown exception', $code = '00000', Exception $e = null) 
+   {
+       parent::__construct($message, $code, $e);
    }
 }

+ 6 - 7
library/Zend/Db/Adapter/Exception.php

@@ -36,23 +36,22 @@ class Zend_Db_Adapter_Exception extends Zend_Db_Exception
 {
     protected $_chainedException = null;
 
-    public function __construct($message = null, Exception $e = null)
+    public function __construct($message = '', $code = 0, Exception $e = null)
     {
-        if ($e) {
-            $this->_chainedException = $e;
-            $this->code = $e->getCode();
+        if ($e && (0 === $code)) {
+            $code = $e->getCode();
         }
-        parent::__construct($message);
+        parent::__construct($message, $code, $e);
     }
 
     public function hasChainedException()
     {
-        return ($this->_chainedException!==null);
+        return ($this->_previous !== null);
     }
 
     public function getChainedException()
     {
-        return $this->_chainedException;
+        return $this->getPrevious();
     }
 
 }

+ 2 - 2
library/Zend/Db/Adapter/Pdo/Abstract.php

@@ -141,7 +141,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
              * @see Zend_Db_Adapter_Exception
              */
             require_once 'Zend/Db/Adapter/Exception.php';
-            throw new Zend_Db_Adapter_Exception($e->getMessage(), $e);
+            throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
     }
@@ -277,7 +277,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
              * @see Zend_Db_Adapter_Exception
              */
             require_once 'Zend/Db/Adapter/Exception.php';
-            throw new Zend_Db_Adapter_Exception($e->getMessage(), $e);
+            throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
         }
     }
 

+ 2 - 2
library/Zend/Db/Adapter/Pdo/Ibm.php

@@ -134,9 +134,9 @@ class Zend_Db_Adapter_Pdo_Ibm extends Zend_Db_Adapter_Pdo_Abstract
             require_once 'Zend/Db/Adapter/Exception.php';
             $error = strpos($e->getMessage(), 'driver does not support that attribute');
             if ($error) {
-                throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel.  Please use driver release version 1.2.1 or later");
+                throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel.  Please use driver release version 1.2.1 or later", 0, $e);
             } else {
-                throw new Zend_Db_Adapter_Exception($e->getMessage());
+                throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
     }

+ 2 - 19
library/Zend/Db/Statement/Exception.php

@@ -37,30 +37,13 @@ require_once 'Zend/Db/Exception.php';
 class Zend_Db_Statement_Exception extends Zend_Db_Exception
 {
     /**
-     * @var Exception
-     */
-    protected $_chainedException = null;
-
-    /**
-     * @param string $message
-     * @param string|int $code
-     * @param Exception $chainedException
-     */
-    public function __construct($message = null, $code = null, Exception $chainedException=null)
-    {
-        $this->message = $message;
-        $this->code = $code;
-        $this->_chainedException = $chainedException;
-    }
-
-    /**
      * Check if this general exception has a specific database driver specific exception nested inside.
      *
      * @return bool
      */
     public function hasChainedException()
     {
-        return ($this->_chainedException!==null);
+        return ($this->_previous !== null);
     }
 
     /**
@@ -68,6 +51,6 @@ class Zend_Db_Statement_Exception extends Zend_Db_Exception
      */
     public function getChainedException()
     {
-        return $this->_chainedException;
+        return $this->_previous;
     }
 }

+ 2 - 2
library/Zend/Db/Table/Row/Abstract.php

@@ -1083,7 +1083,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
                 Zend_Loader::loadClass($rowsetClass);
             } catch (Zend_Exception $e) {
                 require_once 'Zend/Db/Table/Row/Exception.php';
-                throw new Zend_Db_Table_Row_Exception($e->getMessage());
+                throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
         $rowset = new $rowsetClass($config);
@@ -1177,7 +1177,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
                 Zend_Loader::loadClass($tableName);
             } catch (Zend_Exception $e) {
                 require_once 'Zend/Db/Table/Row/Exception.php';
-                throw new Zend_Db_Table_Row_Exception($e->getMessage());
+                throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
 

+ 1 - 1
library/Zend/Db/Table/Rowset/Abstract.php

@@ -391,7 +391,7 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
             $row = $this->current();
         } catch (Zend_Db_Table_Rowset_Exception $e) {
             require_once 'Zend/Db/Table/Rowset/Exception.php';
-            throw new Zend_Db_Table_Rowset_Exception('No row could be found at position ' . (int) $position);
+            throw new Zend_Db_Table_Rowset_Exception('No row could be found at position ' . (int) $position, 0, $e);
         }
         if ($seek == false) {
             $this->seek($key);

+ 62 - 9
library/Zend/Exception.php

@@ -16,16 +16,69 @@
  * @package    Zend
  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * @version    $Id$
  */
 
+if (version_compare(PHP_VERSION, '5.3.0', '<')) {
+    /**
+     * @category   Zend
+     * @package    Zend
+     * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+     * @license    http://framework.zend.com/license/new-bsd     New BSD License
+     */
+    class Zend_Exception extends Exception
+    {
+        /**
+         * @var null|Exception
+         */
+        private $_previous = null;
 
-/**
- * @category   Zend
- * @package    Zend
- * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Exception extends Exception
-{}
+        /**
+         * Construct the exception
+         *
+         * @param  string $msg
+         * @param  int $code
+         * @param  Exception $previous
+         * @return void
+         */
+        public function __construct($msg = '', $code = 0, Exception $previous = null)
+        {
+            parent::__construct($msg, $code);
+            $this->_previous = $previous;
+        }
+
+        /**
+         * Returns previous Exception
+         *
+         * @return Exception|null
+         */
+        final public function getPrevious()
+        {
+            return $this->_previous;
+        }
 
+        /**
+         * String representation of the exception
+         *
+         * @return string
+         */
+        public function __toString()
+        {
+            if (null !== ($e = $this->getPrevious())) {
+                return $e->__toString() 
+                    . "\n\nNext " 
+                    . parent::__toString();
+            }
+            return parent::__toString();
+        }
+    }
+} else {
+    /**
+     * @category   Zend
+     * @package    Zend
+     * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+     * @license    http://framework.zend.com/license/new-bsd     New BSD License
+     */
+    class Zend_Exception extends Exception
+    {
+    }
+}

+ 2 - 1
library/Zend/Feed/Reader/Entry/Rss.php

@@ -273,7 +273,8 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen
                             throw new Zend_Feed_Exception(
                                 'Could not load date due to unrecognised'
                                 .' format (should follow RFC 822 or 2822):'
-                                . $e->getMessage()
+                                . $e->getMessage(),
+                                0, $e
                             );
                         }
                     }

+ 2 - 1
library/Zend/Feed/Reader/Feed/Rss.php

@@ -213,7 +213,8 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract
                             throw new Zend_Feed_Exception(
                                 'Could not load date due to unrecognised'
                                 .' format (should follow RFC 822 or 2822):'
-                                . $e->getMessage()
+                                . $e->getMessage(),
+                                0, $e
                             );
                         }
                     }

+ 1 - 1
library/Zend/Filter/Compress/Tar.php

@@ -62,7 +62,7 @@ class Zend_Filter_Compress_Tar extends Zend_Filter_Compress_CompressAbstract
                 Zend_Loader::loadClass('Archive_Tar');
             } catch (Zend_Exception $e) {
                 require_once 'Zend/Filter/Exception.php';
-                throw new Zend_Filter_Exception('This filter needs PEARs Archive_Tar');
+                throw new Zend_Filter_Exception('This filter needs PEARs Archive_Tar', 0, $e);
             }
         }
 

+ 1 - 1
library/Zend/Http/Client.php

@@ -842,7 +842,7 @@ class Zend_Http_Client
                 } catch (Zend_Exception $e) {
                     /** @see Zend_Http_Client_Exception */
                     require_once 'Zend/Http/Client/Exception.php';
-                    throw new Zend_Http_Client_Exception("Unable to load adapter '$adapter': {$e->getMessage()}");
+                    throw new Zend_Http_Client_Exception("Unable to load adapter '$adapter': {$e->getMessage()}", 0, $e);
                 }
             }
 

+ 1 - 1
library/Zend/Json/Server.php

@@ -529,7 +529,7 @@ class Zend_Json_Server extends Zend_Server_Abstract
         try {
             $result = $this->_dispatch($invocable, $params);
         } catch (Exception $e) {
-            return $this->fault($e->getMessage(), $e->getCode());
+            return $this->fault($e->getMessage(), $e->getCode(), $e);
         }
 
         $this->getResponse()->setResult($result);

+ 2 - 2
library/Zend/Mail/Storage/Folder/Maildir.php

@@ -239,7 +239,7 @@ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir impleme
                  * @see Zend_Mail_Storage_Exception
                  */
                 require_once 'Zend/Mail/Storage/Exception.php';
-                throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable");
+                throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable", 0, $e);
             }
             // seems like file has vanished; rebuilding folder tree - but it's still an exception
             $this->_buildFolderTree($this->_rootdir);
@@ -248,7 +248,7 @@ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir impleme
              */
             require_once 'Zend/Mail/Storage/Exception.php';
             throw new Zend_Mail_Storage_Exception('seems like the maildir has vanished, I\'ve rebuild the ' .
-                                                         'folder tree, search for an other folder and try again');
+                                                         'folder tree, search for an other folder and try again', 0, $e);
         }
     }
 

+ 2 - 2
library/Zend/Mail/Storage/Folder/Mbox.php

@@ -213,7 +213,7 @@ class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Ze
                  * @see Zend_Mail_Storage_Exception
                  */
                 require_once 'Zend/Mail/Storage/Exception.php';
-                throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable");
+                throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable", 0, $e);
             }
             // seems like file has vanished; rebuilding folder tree - but it's still an exception
             $this->_buildFolderTree($this->_rootdir);
@@ -222,7 +222,7 @@ class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Ze
              */
             require_once 'Zend/Mail/Storage/Exception.php';
             throw new Zend_Mail_Storage_Exception('seems like the mbox file has vanished, I\'ve rebuild the ' .
-                                                         'folder tree, search for an other folder and try again');
+                                                         'folder tree, search for an other folder and try again', 0, $e);
         }
     }
 

+ 1 - 1
library/Zend/Mail/Storage/Imap.php

@@ -251,7 +251,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract
                  * @see Zend_Mail_Storage_Exception
                  */
                 require_once 'Zend/Mail/Storage/Exception.php';
-                throw new Zend_Mail_Storage_Exception('cannot select INBOX, is this a valid transport?');
+                throw new Zend_Mail_Storage_Exception('cannot select INBOX, is this a valid transport?', 0, $e);
             }
             return;
         }

+ 1 - 1
library/Zend/Mail/Storage/Writable/Maildir.php

@@ -873,7 +873,7 @@ class Zend_Mail_Storage_Writable_Maildir extends    Zend_Mail_Storage_Folder_Mai
             try {
                 $quota = $this->getQuota(true);
             } catch (Zend_Mail_Storage_Exception $e) {
-                throw new Zend_Mail_Storage_Exception('no quota defintion found');
+                throw new Zend_Mail_Storage_Exception('no quota definition found', 0, $e);
             }
         }
 

+ 1 - 1
library/Zend/Measure/Abstract.php

@@ -200,7 +200,7 @@ abstract class Zend_Measure_Abstract
             $value = Zend_Locale_Format::getNumber($value, array('locale' => $locale));
         } catch(Exception $e) {
             require_once 'Zend/Measure/Exception.php';
-            throw new Zend_Measure_Exception($e->getMessage());
+            throw new Zend_Measure_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         $this->_value = $value;

+ 1 - 1
library/Zend/Measure/Number.php

@@ -256,7 +256,7 @@ class Zend_Measure_Number extends Zend_Measure_Abstract
                     $value = Zend_Locale_Format::getInteger($value, array('locale' => $locale));
                 } catch (Exception $e) {
                     require_once 'Zend/Measure/Exception.php';
-                    throw new Zend_Measure_Exception($e->getMessage());
+                    throw new Zend_Measure_Exception($e->getMessage(), $e->getCode(), $e);
                 }
                 if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) {
                     $value = call_user_func(Zend_Locale_Math::$sqrt, call_user_func(Zend_Locale_Math::$pow, $value, 2));

+ 4 - 3
library/Zend/Pdf/FileParser/Font/OpenType.php

@@ -500,11 +500,11 @@ abstract class Zend_Pdf_FileParser_Font_OpenType extends Zend_Pdf_FileParser_Fon
 
         try {
             $this->_jumpToTable('OS/2');
-        } catch (Zend_Pdf_Exception $exception) {
+        } catch (Zend_Pdf_Exception $e) {
             /* This table is not always present. If missing, use default values.
              */
             require_once 'Zend/Pdf/Exception.php';
-            if ($exception->getCode() == Zend_Pdf_Exception::REQUIRED_TABLE_NOT_FOUND) {
+            if ($e->getCode() == Zend_Pdf_Exception::REQUIRED_TABLE_NOT_FOUND) {
                 $this->_debugLog('No OS/2 table found. Using default values');
                 $this->fontWeight = Zend_Pdf_Font::WEIGHT_NORMAL;
                 $this->fontWidth = Zend_Pdf_Font::WIDTH_NORMAL;
@@ -525,7 +525,8 @@ abstract class Zend_Pdf_FileParser_Font_OpenType extends Zend_Pdf_FileParser_Fon
             } else {
                 /* Something else went wrong. Throw this exception higher up the chain.
                  */
-                throw $exception;
+                throw $e;
+                throw new Zend_Pdf_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
 

+ 3 - 3
library/Zend/Pdf/Font.php

@@ -709,7 +709,7 @@ abstract class Zend_Pdf_Font
                 $cidFont = new Zend_Pdf_Resource_Font_CidFont_TrueType($fontParser, $embeddingOptions);
                 $font    = new Zend_Pdf_Resource_Font_Type0($cidFont);
             }
-        } catch (Zend_Pdf_Exception $exception) {
+        } catch (Zend_Pdf_Exception $e) {
             /* The following exception codes suggest that this isn't really a
              * TrueType font. If we caught such an exception, simply return
              * null. For all other cases, it probably is a TrueType font but has
@@ -717,14 +717,14 @@ abstract class Zend_Pdf_Font
              */
             $fontParser = null;
             require_once 'Zend/Pdf/Exception.php';
-            switch ($exception->getCode()) {
+            switch ($e->getCode()) {
                 case Zend_Pdf_Exception::WRONG_FONT_TYPE:    // break intentionally omitted
                 case Zend_Pdf_Exception::BAD_TABLE_COUNT:    // break intentionally omitted
                 case Zend_Pdf_Exception::BAD_MAGIC_NUMBER:
                     return null;
 
                 default:
-                    throw $exception;
+                    throw new Zend_Pdf_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
         return $font;

+ 2 - 2
library/Zend/Pdf/Page.php

@@ -759,7 +759,7 @@ class Zend_Pdf_Page
                 $fonts[$resourceId] = $extractedFont;
             } catch (Zend_Pdf_Exception $e) {
                 if ($e->getMessage() != 'Unsupported font type.') {
-                    throw $e;
+                    throw new Zend_Pdf_Exception($e->getMessage(), $e->getCode(), $e);
                 }
             }
         }
@@ -814,7 +814,7 @@ class Zend_Pdf_Page
                 return new Zend_Pdf_Resource_Font_Extracted($fontDictionary);
             } catch (Zend_Pdf_Exception $e) {
                 if ($e->getMessage() != 'Unsupported font type.') {
-                    throw $e;
+                    throw new Zend_Pdf_Exception($e->getMessage(), $e->getCode(), $e);
                 }
 
                 // Continue searhing font with specified name

+ 1 - 1
library/Zend/Pdf/Trailer/Keeper.php

@@ -137,7 +137,7 @@ class Zend_Pdf_Trailer_Keeper extends Zend_Pdf_Trailer
                 return 0;
             }
 
-            throw $e;
+            throw new Zend_Pdf_Exception($e->getMessage(), $e->getCode(), $e);
         }
     }
 }

+ 5 - 5
library/Zend/Queue/Adapter/Db.php

@@ -152,7 +152,7 @@ class Zend_Queue_Adapter_Db extends Zend_Queue_Adapter_AdapterAbstract
             $db = Zend_Db::factory($type, $options);
         } catch (Zend_Db_Exception $e) {
             require_once 'Zend/Queue/Exception.php';
-            throw new Zend_Queue_Exception('Error connecting to database: ' . $e->getMessage(), $e->getCode());
+            throw new Zend_Queue_Exception('Error connecting to database: ' . $e->getMessage(), $e->getCode(), $e);
         }
 
         return $db;
@@ -215,7 +215,7 @@ class Zend_Queue_Adapter_Db extends Zend_Queue_Adapter_AdapterAbstract
             }
         } catch (Exception $e) {
             require_once 'Zend/Queue/Exception.php';
-            throw new Zend_Queue_Exception($e->getMessage(), $e->getCode());
+            throw new Zend_Queue_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         return false;
@@ -246,7 +246,7 @@ class Zend_Queue_Adapter_Db extends Zend_Queue_Adapter_AdapterAbstract
                 $queue->delete();
             } catch (Exception $e) {
                 require_once 'Zend/Queue/Exception.php';
-                throw new Zend_Queue_Exception($e->getMessage(), $e->getCode());
+                throw new Zend_Queue_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
 
@@ -349,7 +349,7 @@ class Zend_Queue_Adapter_Db extends Zend_Queue_Adapter_AdapterAbstract
             $msg->save();
         } catch (Exception $e) {
             require_once 'Zend/Queue/Exception.php';
-            throw new Zend_Queue_Exception($e->getMessage(), $e->getCode());
+            throw new Zend_Queue_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         $options = array(
@@ -434,7 +434,7 @@ class Zend_Queue_Adapter_Db extends Zend_Queue_Adapter_AdapterAbstract
             $db->rollBack();
 
             require_once 'Zend/Queue/Exception.php';
-            throw new Zend_Queue_Exception($e->getMessage(), $e->getCode());
+            throw new Zend_Queue_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         $options = array(

+ 1 - 1
library/Zend/Rest/Server.php

@@ -602,7 +602,7 @@ class Zend_Rest_Server implements Zend_Server_Interface
             throw new Zend_Rest_Server_Exception('Error instantiating class ' . $class .
                                                  ' to invoke method ' . $this->_functions[$this->_method]->getName() .
                                                  ' (' . $e->getMessage() . ') ',
-                                                 500);
+                                                 500, $e);
         }
 
         try {

+ 5 - 5
library/Zend/Search/Lucene.php

@@ -290,11 +290,11 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
                     if (strpos($e->getMessage(), 'is not readable') !== false) {
                         return -1;
                     } else {
-                        throw $e;
+                        throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
                     }
                 }
             } else {
-                throw $e;
+                throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
 
@@ -521,9 +521,9 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
                 Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory);
 
                 if (strpos($e->getMessage(), 'Can\'t obtain exclusive index lock') === false) {
-                    throw $e;
+                    throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
                 } else {
-                    throw new Zend_Search_Lucene_Exception('Can\'t create index. It\'s under processing now');
+                    throw new Zend_Search_Lucene_Exception('Can\'t create index. It\'s under processing now', 0, $e);
                 }
             }
 
@@ -1000,7 +1000,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
                             $value = $hit->getDocument()->getFieldValue($fieldName);
                         } catch (Zend_Search_Lucene_Exception $e) {
                             if (strpos($e->getMessage(), 'not found') === false) {
-                                throw $e;
+                                throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
                             } else {
                                 $value = null;
                             }

+ 2 - 2
library/Zend/Search/Lucene/Index/SegmentInfo.php

@@ -276,7 +276,7 @@ class Zend_Search_Lucene_Index_SegmentInfo implements Zend_Search_Lucene_Index_T
                     // Compound file is not found or is not readable
                     $this->_isCompound = false;
                 } else {
-                    throw $e;
+                    throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
                 }
             }
         }
@@ -401,7 +401,7 @@ class Zend_Search_Lucene_Index_SegmentInfo implements Zend_Search_Lucene_Index_T
             }
         } catch(Zend_Search_Lucene_Exception $e) {
             if (strpos($e->getMessage(), 'is not readable') === false) {
-                throw $e;
+                throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
             }
             // There is no deletion file
             $this->_delGen = -1;

+ 4 - 3
library/Zend/Search/Lucene/Index/Writer.php

@@ -416,7 +416,7 @@ class Zend_Search_Lucene_Index_Writer
             if (strpos($e->getMessage(), 'is not readable') !== false) {
                 $genFile = $this->_directory->createFile('segments.gen');
             } else {
-                throw $e;
+                throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
 
@@ -603,7 +603,8 @@ class Zend_Search_Lucene_Index_Writer
             Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
 
             // Throw the exception
-            throw $e;
+            require_once 'Zend/Search/Lucene/Exception.php';
+            throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
         }
 
         // Write generation (second copy)
@@ -716,7 +717,7 @@ class Zend_Search_Lucene_Index_Writer
                     if (strpos($e->getMessage(), 'Can\'t delete file') === false) {
                         // That's not "file is under processing or already deleted" exception
                         // Pass it through
-                        throw $e;
+                        throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
                     }
                 }
             }

+ 5 - 3
library/Zend/Search/Lucene/Search/QueryParser.php

@@ -372,10 +372,11 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
                     self::$_instance->_lastToken = $token;
                 } catch (Exception $e) {
                     if (strpos($e->getMessage(), 'There is no any rule for') !== false) {
-                        throw new Zend_Search_Lucene_Search_QueryParserException( 'Syntax error at char position ' . $token->position . '.' );
+                        throw new Zend_Search_Lucene_Search_QueryParserException( 'Syntax error at char position ' . $token->position . '.', 0, $e);
                     }
 
-                    throw $e;
+                    require_once 'Zend/Search/Lucene/Exception.php';
+                    throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
                 }
             }
 
@@ -401,7 +402,8 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
 
                 return $query;
             } else {
-                throw $e;
+                require_once 'Zend/Search/Lucene/Exception.php';
+                throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
     }

+ 1 - 1
library/Zend/Search/Lucene/Search/QueryParserContext.php

@@ -327,7 +327,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
             //                                                          $e->getMessage() . '\'.' );
             // It's query syntax error message and it should be user friendly. So FSM message is omitted
             require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
-            throw new Zend_Search_Lucene_Search_QueryParserException('Boolean expression error.');
+            throw new Zend_Search_Lucene_Search_QueryParserException('Boolean expression error.', 0, $e);
         }
 
         // Remove 'only negative' conjunctions

+ 1 - 1
library/Zend/Service/Amazon/Ec2/Abstract.php

@@ -170,7 +170,7 @@ abstract class Zend_Service_Amazon_Ec2_Abstract extends Zend_Service_Amazon_Abst
 
         } catch (Zend_Http_Client_Exception $zhce) {
             $message = 'Error in request to AWS service: ' . $zhce->getMessage();
-            throw new Zend_Service_Amazon_Ec2_Exception($message, $zhce->getCode());
+            throw new Zend_Service_Amazon_Ec2_Exception($message, $zhce->getCode(), $zhce);
         }
         $response = new Zend_Service_Amazon_Ec2_Response($httpResponse);
         $this->checkForErrors($response);

+ 3 - 3
library/Zend/Service/SlideShare.php

@@ -354,7 +354,7 @@ class Zend_Service_SlideShare
             $response = $client->request('POST');
         } catch(Zend_Http_Client_Exception $e) {
             require_once 'Zend/Service/SlideShare/Exception.php';
-            throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}");
+            throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}", 0, $e);
         }
 
         $sxe = simplexml_load_string($response->getBody());
@@ -406,7 +406,7 @@ class Zend_Service_SlideShare
                 $response = $client->request('POST');
             } catch(Zend_Http_Client_Exception $e) {
                 require_once 'Zend/Service/SlideShare/Exception.php';
-                throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}");
+                throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}", 0, $e);
             }
 
             $sxe = simplexml_load_string($response->getBody());
@@ -544,7 +544,7 @@ class Zend_Service_SlideShare
                 $response = $client->request('POST');
             } catch(Zend_Http_Client_Exception $e) {
                 require_once 'Zend/Service/SlideShare/Exception.php';
-                throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}");
+                throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}", 0, $e);
             }
 
             $sxe = simplexml_load_string($response->getBody());

+ 1 - 1
library/Zend/Service/StrikeIron.php

@@ -81,7 +81,7 @@ class Zend_Service_StrikeIron
              * @see Zend_Service_StrikeIron_Exception
              */
             require_once 'Zend/Service/StrikeIron/Exception.php';
-            throw new Zend_Service_StrikeIron_Exception($msg, $e->getCode());
+            throw new Zend_Service_StrikeIron_Exception($msg, $e->getCode(), $e);
         }
 
         // instantiate and return the service

+ 1 - 1
library/Zend/Service/StrikeIron/Base.php

@@ -103,7 +103,7 @@ class Zend_Service_StrikeIron_Base
              * @see Zend_Service_StrikeIron_Exception
              */
             require_once 'Zend/Service/StrikeIron/Exception.php';
-            throw new Zend_Service_StrikeIron_Exception($message, $e->getCode());
+            throw new Zend_Service_StrikeIron_Exception($message, $e->getCode(), $e);
         }
 
         // transform/decorate the result and return it

+ 1 - 1
library/Zend/Service/Technorati/Utils.php

@@ -64,7 +64,7 @@ class Zend_Service_Technorati_Utils
                  * @see Zend_Service_Technorati_Exception
                  */
                 require_once 'Zend/Service/Technorati/Exception.php';
-                throw new Zend_Service_Technorati_Exception($e->getMessage());
+                throw new Zend_Service_Technorati_Exception($e->getMessage(), 0, $e);
             }
         }
 

+ 4 - 4
library/Zend/Translate/Adapter.php

@@ -165,7 +165,7 @@ abstract class Zend_Translate_Adapter {
             $locale    = Zend_Locale::findLocale($locale);
         } catch (Zend_Locale_Exception $e) {
             require_once 'Zend/Translate/Exception.php';
-            throw new Zend_Translate_Exception("The given Language '{$locale}' does not exist");
+            throw new Zend_Translate_Exception("The given Language '{$locale}' does not exist", 0, $e);
         }
 
         $options  = $options + $this->_options;
@@ -325,7 +325,7 @@ abstract class Zend_Translate_Adapter {
             $locale = Zend_Locale::findLocale($locale);
         } catch (Zend_Locale_Exception $e) {
             require_once 'Zend/Translate/Exception.php';
-            throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist");
+            throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist", 0, $e);
         }
 
         if (!isset($this->_translate[$locale])) {
@@ -464,7 +464,7 @@ abstract class Zend_Translate_Adapter {
             $locale    = Zend_Locale::findLocale($locale);
         } catch (Zend_Locale_Exception $e) {
             require_once 'Zend/Translate/Exception.php';
-            throw new Zend_Translate_Exception("The given Language '{$locale}' does not exist");
+            throw new Zend_Translate_Exception("The given Language '{$locale}' does not exist", 0, $e);
         }
 
         if ($options['clear'] || !isset($this->_translate[$locale])) {
@@ -777,4 +777,4 @@ abstract class Zend_Translate_Adapter {
      * @return string
      */
     abstract public function toString();
-}
+}

+ 33 - 12
library/Zend/View/Abstract.php

@@ -302,7 +302,9 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
         }
 
         require_once 'Zend/View/Exception.php';
-        throw new Zend_View_Exception('Setting private or protected class members is not allowed', $this);
+        $e = new Zend_View_Exception('Setting private or protected class members is not allowed');
+        $e->setView($this);
+        throw $e;
     }
 
     /**
@@ -464,7 +466,9 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
         $type = strtolower($type);
         if (!in_array($type, $this->_loaderTypes)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(sprintf('Invalid plugin loader type "%s"', $type));
+            $e = new Zend_View_Exception(sprintf('Invalid plugin loader type "%s"', $type));
+            $e->setView($this);
+            throw $e;
         }
 
         $this->_loaders[$type] = $loader;
@@ -482,7 +486,9 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
         $type = strtolower($type);
         if (!in_array($type, $this->_loaderTypes)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(sprintf('Invalid plugin loader type "%s"; cannot retrieve', $type));
+            $e = new Zend_View_Exception(sprintf('Invalid plugin loader type "%s"; cannot retrieve', $type));
+            $e->setView($this);
+            throw $e;
         }
 
         if (!array_key_exists($type, $this->_loaders)) {
@@ -568,15 +574,19 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
     {
         if (!is_object($helper)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('View helper must be an object');
+            $e = new Zend_View_Exception('View helper must be an object');
+            $e->setView($this);
+            throw $e;
         }
 
         if (!$helper instanceof Zend_View_Interface) {
             if (!method_exists($helper, $name)) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(
+                $e =  new Zend_View_Exception(
                     'View helper must implement Zend_View_Interface or have a method matching the name provided'
                 );
+                $e->setView($this);
+                throw $e;
             }
         }
 
@@ -785,7 +795,9 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
             // assign by name and value
             if ('_' == substr($spec, 0, 1)) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception('Setting private or protected class members is not allowed', $this);
+                $e = new Zend_View_Exception('Setting private or protected class members is not allowed');
+                $e->setView($this);
+                throw $e;
             }
             $this->$spec = $value;
         } elseif (is_array($spec)) {
@@ -800,11 +812,15 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
             }
             if ($error) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception('Setting private or protected class members is not allowed', $this);
+                $e = new Zend_View_Exception('Setting private or protected class members is not allowed');
+                $e->setView($this);
+                throw $e;
             }
         } else {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('assign() expects a string or array, received ' . gettype($spec), $this);
+            $e = new Zend_View_Exception('assign() expects a string or array, received ' . gettype($spec));
+            $e->setView($this);
+            throw $e;
         }
 
         return $this;
@@ -935,13 +951,16 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
     {
         if ($this->isLfiProtectionOn() && preg_match('#\.\.[\\\/]#', $name)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Requested scripts may not include parent directory traversal ("../", "..\\" notation)');
+            $e = new Zend_View_Exception('Requested scripts may not include parent directory traversal ("../", "..\\" notation)');
+            $e->setView($this);
+            throw $e;
         }
 
         if (0 == count($this->_path['script'])) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('no view script directory set; unable to determine location for view script',
-                $this);
+            $e = new Zend_View_Exception('no view script directory set; unable to determine location for view script');
+            $e->setView($this);
+            throw $e;
         }
 
         foreach ($this->_path['script'] as $dir) {
@@ -954,7 +973,9 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
         $message = "script '$name' not found in path ("
                  . implode(PATH_SEPARATOR, $this->_path['script'])
                  . ")";
-        throw new Zend_View_Exception($message, $this);
+        $e = new Zend_View_Exception($message);
+        $e->setView($this);
+        throw $e;
     }
 
     /**

+ 2 - 2
library/Zend/View/Exception.php

@@ -38,10 +38,10 @@ class Zend_View_Exception extends Zend_Exception
 {
     protected $view = null;
 
-    public function __construct($message, Zend_View_Interface $view = null)
+    public function setView(Zend_View_Interface $view = null)
     {
         $this->view = $view;
-        parent::__construct($message);
+        return $this;
     }
 
     public function getView()

+ 6 - 2
library/Zend/View/Helper/Action.php

@@ -66,7 +66,9 @@ class Zend_View_Helper_Action extends Zend_View_Helper_Abstract
         $modules = $front->getControllerDirectory();
         if (empty($modules)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Action helper depends on valid front controller instance');
+            $e = new Zend_View_Exception('Action helper depends on valid front controller instance');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $request  = $front->getRequest();
@@ -74,7 +76,9 @@ class Zend_View_Helper_Action extends Zend_View_Helper_Abstract
 
         if (empty($request) || empty($response)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Action view helper requires both a registered request and response object in the front controller instance');
+            $e = new Zend_View_Exception('Action view helper requires both a registered request and response object in the front controller instance');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $this->request       = clone $request;

+ 3 - 1
library/Zend/View/Helper/Doctype.php

@@ -124,7 +124,9 @@ class Zend_View_Helper_Doctype extends Zend_View_Helper_Abstract
                 default:
                     if (substr($doctype, 0, 9) != '<!DOCTYPE') {
                         require_once 'Zend/View/Exception.php';
-                        throw new Zend_View_Exception('The specified doctype is malformed');
+                        $e = new Zend_View_Exception('The specified doctype is malformed');
+                        $e->setView($this->view);
+                        throw $e;
                     }
                     if (stristr($doctype, 'xhtml')) {
                         $type = self::CUSTOM_XHTML;

+ 4 - 2
library/Zend/View/Helper/FormElement.php

@@ -66,8 +66,10 @@ abstract class Zend_View_Helper_FormElement extends Zend_View_Helper_HtmlElement
         } elseif ($translator instanceof Zend_Translate) {
             $this->_translator = $translator->getAdapter();
         } else {
-            require_once 'Zend/Form/Exception.php';
-            throw new Zend_Form_Exception('Invalid translator specified');
+            require_once 'Zend/View/Exception.php';
+            $e = new Zend_View_Exception('Invalid translator specified');
+            $e->setView($this->view);
+            throw $e;
         }
          return $this;
     }

+ 18 - 6
library/Zend/View/Helper/HeadLink.php

@@ -140,7 +140,9 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S
 
             if (1 > $argc) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(sprintf('%s requires at least one argument', $method));
+                $e =  new Zend_View_Exception(sprintf('%s requires at least one argument', $method));
+                $e->setView($this->view);
+                throw $e;
             }
 
             if (is_array($args[0])) {
@@ -196,7 +198,9 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('append() expects a data token; please use one of the custom append*() methods');
+            $e = new Zend_View_Exception('append() expects a data token; please use one of the custom append*() methods');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->append($value);
@@ -213,7 +217,9 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('offsetSet() expects a data token; please use one of the custom offsetSet*() methods');
+            $e = new Zend_View_Exception('offsetSet() expects a data token; please use one of the custom offsetSet*() methods');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->offsetSet($index, $value);
@@ -229,7 +235,9 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('prepend() expects a data token; please use one of the custom prepend*() methods');
+            $e = new Zend_View_Exception('prepend() expects a data token; please use one of the custom prepend*() methods');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->prepend($value);
@@ -245,7 +253,9 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('set() expects a data token; please use one of the custom set*() methods');
+            $e = new Zend_View_Exception('set() expects a data token; please use one of the custom set*() methods');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->set($value);
@@ -398,7 +408,9 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S
     {
         if (3 > count($args)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(sprintf('Alternate tags require 3 arguments; %s provided', count($args)));
+            $e = new Zend_View_Exception(sprintf('Alternate tags require 3 arguments; %s provided', count($args)));
+            $e->setView($this->view);
+            throw $e;
         }
 
         $rel   = 'alternate';

+ 24 - 8
library/Zend/View/Helper/HeadMeta.php

@@ -100,7 +100,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
                 return 'http-equiv';
             default:
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(sprintf('Invalid type "%s" passed to _normalizeType', $type));
+                $e = new Zend_View_Exception(sprintf('Invalid type "%s" passed to _normalizeType', $type));
+                $e->setView($this->view);
+                throw $e;
         }
     }
 
@@ -138,7 +140,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
 
             if (2 > $argc) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception('Too few arguments provided; requires key value, and content');
+                $e = new Zend_View_Exception('Too few arguments provided; requires key value, and content');
+                $e->setView($this->view);
+                throw $e;
             }
 
             if (3 > $argc) {
@@ -192,7 +196,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid value passed to append; please use appendMeta()');
+            $e = new Zend_View_Exception('Invalid value passed to append; please use appendMeta()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->append($value);
@@ -210,7 +216,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetMeta()');
+            $e =  new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetMeta()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->offsetSet($index, $value);
@@ -227,7 +235,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!in_array($index, $this->getContainer()->getKeys())) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid index passed to offsetUnset.');
+            $e = new Zend_View_Exception('Invalid index passed to offsetUnset()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->offsetUnset($index);
@@ -244,7 +254,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid value passed to prepend; please use prependMeta()');
+            $e = new Zend_View_Exception('Invalid value passed to prepend; please use prependMeta()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->prepend($value);
@@ -261,7 +273,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid value passed to set; please use setMeta()');
+            $e = new Zend_View_Exception('Invalid value passed to set; please use setMeta()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $container = $this->getContainer();
@@ -287,7 +301,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
     {
         if (!in_array($item->type, $this->_typeKeys)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(sprintf('Invalid type "%s" provided for meta', $item->type));
+            $e = new Zend_View_Exception(sprintf('Invalid type "%s" provided for meta', $item->type));
+            $e->setView($this->view);
+            throw $e;
         }
         $type = $item->type;
 

+ 21 - 7
library/Zend/View/Helper/HeadScript.php

@@ -143,7 +143,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
     {
         if ($this->_captureLock) {
             require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
-            throw new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest headScript captures');
+            $e = new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest headScript captures');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $this->_captureLock        = true;
@@ -203,7 +205,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
         if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<mode>File|Script)$/', $method, $matches)) {
             if (1 > count($args)) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(sprintf('Method "%s" requires at least one argument', $method));
+                $e = new Zend_View_Exception(sprintf('Method "%s" requires at least one argument', $method));
+                $e->setView($this->view);
+                throw $e;
             }
 
             $action  = $matches['action'];
@@ -215,7 +219,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
                 $index = array_shift($args);
                 if (1 > count($args)) {
                     require_once 'Zend/View/Exception.php';
-                    throw new Zend_View_Exception(sprintf('Method "%s" requires at least two arguments, an index and source', $method));
+                    $e = new Zend_View_Exception(sprintf('Method "%s" requires at least two arguments, an index and source', $method));
+                    $e->setView($this->view);
+                    throw $e;
                 }
             }
 
@@ -305,7 +311,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid argument passed to append(); please use one of the helper methods, appendScript() or appendFile()');
+            $e = new Zend_View_Exception('Invalid argument passed to append(); please use one of the helper methods, appendScript() or appendFile()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->append($value);
@@ -321,7 +329,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid argument passed to prepend(); please use one of the helper methods, prependScript() or prependFile()');
+            $e = new Zend_View_Exception('Invalid argument passed to prepend(); please use one of the helper methods, prependScript() or prependFile()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->prepend($value);
@@ -337,7 +347,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid argument passed to set(); please use one of the helper methods, setScript() or setFile()');
+            $e = new Zend_View_Exception('Invalid argument passed to set(); please use one of the helper methods, setScript() or setFile()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->set($value);
@@ -354,7 +366,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()');
+            $e = new Zend_View_Exception('Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $this->_isValid($value);

+ 18 - 6
library/Zend/View/Helper/HeadStyle.php

@@ -147,7 +147,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
 
             if (1 > $argc) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(sprintf('Method "%s" requires minimally content for the stylesheet', $method));
+                $e = new Zend_View_Exception(sprintf('Method "%s" requires minimally content for the stylesheet', $method));
+                $e->setView($this->view);
+                throw $e;
             }
 
             $content = $args[0];
@@ -199,7 +201,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid value passed to append; please use appendStyle()');
+            $e = new Zend_View_Exception('Invalid value passed to append; please use appendStyle()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->append($value);
@@ -216,7 +220,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetStyle()');
+            $e = new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetStyle()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->offsetSet($index, $value);
@@ -232,7 +238,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid value passed to prepend; please use prependStyle()');
+            $e = new Zend_View_Exception('Invalid value passed to prepend; please use prependStyle()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->prepend($value);
@@ -248,7 +256,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
     {
         if (!$this->_isValid($value)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid value passed to set; please use setStyle()');
+            $e = new Zend_View_Exception('Invalid value passed to set; please use setStyle()');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this->getContainer()->set($value);
@@ -265,7 +275,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
     {
         if ($this->_captureLock) {
             require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
-            throw new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest headStyle captures');
+            $e = new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest headStyle captures');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $this->_captureLock        = true;

+ 3 - 1
library/Zend/View/Helper/HeadTitle.php

@@ -91,7 +91,9 @@ class Zend_View_Helper_HeadTitle extends Zend_View_Helper_Placeholder_Container_
             $this->_translator = $translate->getAdapter();
         } else {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
+            $e = new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
+            $e->setView($this->view);
+            throw $e;
         }
         return $this;
     }

+ 3 - 1
library/Zend/View/Helper/HtmlList.php

@@ -51,7 +51,9 @@ class Zend_View_Helper_HtmlList extends Zend_View_Helper_FormElement
     {
         if (!is_array($items)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('First param must be an array', $this);
+            $e = new Zend_View_Exception('First param must be an array');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $list = '';

+ 3 - 1
library/Zend/View/Helper/Navigation.php

@@ -175,10 +175,12 @@ class Zend_View_Helper_Navigation
         if (!$helper instanceof Zend_View_Helper_Navigation_Helper) {
             if ($strict) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(sprintf(
+                $e = new Zend_View_Exception(sprintf(
                         'Proxy helper "%s" is not an instance of ' .
                         'Zend_View_Helper_Navigation_Helper',
                         get_class($helper)));
+                $e->setView($this->view);
+                throw $e;
             }
 
             return null;

+ 12 - 6
library/Zend/View/Helper/Navigation/Breadcrumbs.php

@@ -260,8 +260,11 @@ class Zend_View_Helper_Navigation_Breadcrumbs
 
         if (empty($partial)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(
-                    'Unable to render menu: No partial view script provided');
+            $e = new Zend_View_Exception(
+                'Unable to render menu: No partial view script provided'
+            );
+            $e->setView($this->view);
+            throw $e;
         }
 
         // put breadcrumb pages in model
@@ -289,10 +292,13 @@ class Zend_View_Helper_Navigation_Breadcrumbs
         if (is_array($partial)) {
             if (count($partial) != 2) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(
-                        'Unable to render menu: A view partial supplied as ' .
-                        'an array must contain two values: partial view ' .
-                        'script and module where script can be found');
+                $e = new Zend_View_Exception(
+                    'Unable to render menu: A view partial supplied as ' 
+                    .  'an array must contain two values: partial view ' 
+                    .  'script and module where script can be found'
+                );
+                $e->setView($this->view);
+                throw $e;
             }
 
             return $this->view->partial($partial[0], $partial[1], $model);

+ 9 - 5
library/Zend/View/Helper/Navigation/HelperAbstract.php

@@ -376,10 +376,13 @@ abstract class Zend_View_Helper_Navigation_HelperAbstract
             $this->_role = $role;
         } else {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(sprintf(
-                    '$role must be a string, null, or an instance of ' .
-                            'Zend_Acl_Role_Interface; %s given',
-                    gettype($role)));
+            $e = new Zend_View_Exception(sprintf(
+                '$role must be a string, null, or an instance of ' 
+                .  'Zend_Acl_Role_Interface; %s given',
+                gettype($role)
+            ));
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this;
@@ -845,7 +848,8 @@ abstract class Zend_View_Helper_Navigation_HelperAbstract
         } else {
             require_once 'Zend/View/Exception.php';
             throw new Zend_View_Exception(
-                    '$role must be null|string|Zend_Acl_Role_Interface');
+                '$role must be null|string|Zend_Acl_Role_Interface'
+            );
         }
     }
 }

+ 6 - 2
library/Zend/View/Helper/Navigation/Links.php

@@ -271,9 +271,11 @@ class Zend_View_Helper_Navigation_Links
     {
         if (!in_array($rel, array('rel', 'rev'))) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(sprintf(
+            $e = new Zend_View_Exception(sprintf(
                 'Invalid argument: $rel must be "rel" or "rev"; "%s" given',
                 $rel));
+            $e->setView($this->view);
+            throw $e;
         }
 
         if (!$result = $this->_findFromProperty($page, $rel, $type)) {
@@ -708,9 +710,11 @@ class Zend_View_Helper_Navigation_Links
     {
         if (!in_array($attrib, array('rel', 'rev'))) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(sprintf(
+            $e = new Zend_View_Exception(sprintf(
                     'Invalid relation attribute "%s", must be "rel" or "rev"',
                     $attrib));
+            $e->setView($this->view);
+            throw $e;
         }
 
         if (!$href = $page->getHref()) {

+ 12 - 6
library/Zend/View/Helper/Navigation/Menu.php

@@ -587,8 +587,11 @@ class Zend_View_Helper_Navigation_Menu
 
         if (empty($partial)) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception(
-                    'Unable to render menu: No partial view script provided');
+            $e = new Zend_View_Exception(
+                'Unable to render menu: No partial view script provided'
+            );
+            $e->setView($this->view);
+            throw $e;
         }
 
         $model = array(
@@ -598,10 +601,13 @@ class Zend_View_Helper_Navigation_Menu
         if (is_array($partial)) {
             if (count($partial) != 2) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(
-                        'Unable to render menu: A view partial supplied as ' .
-                        'an array must contain two values: partial view ' .
-                        'script and module where script can be found');
+                $e = new Zend_View_Exception(
+                    'Unable to render menu: A view partial supplied as ' 
+                    .  'an array must contain two values: partial view ' 
+                    .  'script and module where script can be found'
+                );
+                $e->setView($this->view);
+                throw $e;
             }
 
             return $this->view->partial($partial[0], $partial[1], $model);

+ 9 - 3
library/Zend/View/Helper/Navigation/Sitemap.php

@@ -228,9 +228,11 @@ class Zend_View_Helper_Navigation_Sitemap
             $this->_serverUrl = $uri->getUri();
         } else {
             require_once 'Zend/Uri/Exception.php';
-            throw new Zend_Uri_Exception(sprintf(
+            $e = new Zend_Uri_Exception(sprintf(
                     'Invalid server URL: "%s"',
                     $serverUrl));
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this;
@@ -379,9 +381,11 @@ class Zend_View_Helper_Navigation_Sitemap
             if ($this->getUseSitemapValidators() &&
                 !$locValidator->isValid($url)) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(sprintf(
+                $e = new Zend_View_Exception(sprintf(
                         'Encountered an invalid URL for Sitemap XML: "%s"',
                         $url));
+                $e->setView($this->view);
+                throw $e;
             }
 
             // put url in 'loc' element
@@ -435,9 +439,11 @@ class Zend_View_Helper_Navigation_Sitemap
         if ($this->getUseSchemaValidation()) {
             if (!@$dom->schemaValidate(self::SITEMAP_XSD)) {
                 require_once 'Zend/View/Exception.php';
-                throw new Zend_View_Exception(sprintf(
+                $e = new Zend_View_Exception(sprintf(
                         'Sitemap is invalid according to XML Schema at "%s"',
                         self::SITEMAP_XSD));
+                $e->setView($this->view);
+                throw $e;
             }
         }
 

+ 10 - 6
library/Zend/View/Helper/PaginationControl.php

@@ -96,7 +96,9 @@ class Zend_View_Helper_PaginationControl
                  */
                 require_once 'Zend/View/Exception.php';
 
-                throw new Zend_View_Exception('No paginator instance provided or incorrect type');
+                $e = new Zend_View_Exception('No paginator instance provided or incorrect type');
+                $e->setView($this->view);
+                throw $e;
             }
         }
 
@@ -106,8 +108,9 @@ class Zend_View_Helper_PaginationControl
                  * @see Zend_View_Exception
                  */
                 require_once 'Zend/View/Exception.php';
-
-                throw new Zend_View_Exception('No view partial provided and no default set');
+                $e = new Zend_View_Exception('No view partial provided and no default set');
+                $e->setView($this->view);
+                throw $e;
             }
 
             $partial = self::$_defaultViewPartial;
@@ -125,8 +128,9 @@ class Zend_View_Helper_PaginationControl
                  * @see Zend_View_Exception
                  */
                 require_once 'Zend/View/Exception.php';
-
-                throw new Zend_View_Exception('A view partial supplied as an array must contain two values: the filename and its module');
+                $e = new Zend_View_Exception('A view partial supplied as an array must contain two values: the filename and its module');
+                $e->setView($this->view);
+                throw $e;
             }
 
             if ($partial[1] !== null) {
@@ -138,4 +142,4 @@ class Zend_View_Helper_PaginationControl
 
         return $this->view->partial($partial, $pages);
     }
-}
+}

+ 3 - 1
library/Zend/View/Helper/Partial.php

@@ -76,7 +76,9 @@ class Zend_View_Helper_Partial extends Zend_View_Helper_Abstract
             $moduleDir = Zend_Controller_Front::getInstance()->getControllerDirectory($module);
             if (null === $moduleDir) {
                 require_once 'Zend/View/Helper/Partial/Exception.php';
-                throw new Zend_View_Helper_Partial_Exception('Cannot render partial; module does not exist');
+                $e = new Zend_View_Helper_Partial_Exception('Cannot render partial; module does not exist');
+                $e->setView($this->view);
+                throw $e;
             }
             $viewsDir = dirname($moduleDir) . '/views';
             $view->addBasePath($viewsDir);

+ 3 - 1
library/Zend/View/Helper/PartialLoop.php

@@ -71,7 +71,9 @@ class Zend_View_Helper_PartialLoop extends Zend_View_Helper_Partial
             && (is_object($model) && !method_exists($model, 'toArray'))
         ) {
             require_once 'Zend/View/Helper/Partial/Exception.php';
-            throw new Zend_View_Helper_Partial_Exception('PartialLoop helper requires iterable data');
+            $e = new Zend_View_Helper_Partial_Exception('PartialLoop helper requires iterable data');
+            $e->setView($this->view);
+            throw $e;
         }
 
         if (is_object($model)

+ 3 - 1
library/Zend/View/Helper/Placeholder/Container/Abstract.php

@@ -260,7 +260,9 @@ abstract class Zend_View_Helper_Placeholder_Container_Abstract extends ArrayObje
     {
         if ($this->_captureLock) {
             require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
-            throw new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest placeholder captures for the same placeholder');
+            $e = new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest placeholder captures for the same placeholder');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $this->_captureLock = true;

+ 3 - 1
library/Zend/View/Helper/Placeholder/Container/Standalone.php

@@ -228,7 +228,9 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
         }
 
         require_once 'Zend/View/Exception.php';
-        throw new Zend_View_Exception('Method "' . $method . '" does not exist');
+        $e = new Zend_View_Exception('Method "' . $method . '" does not exist');
+        $e->setView($this->view);
+        throw $e;
     }
 
     /**

+ 3 - 1
library/Zend/View/Helper/Placeholder/Registry.php

@@ -167,7 +167,9 @@ class Zend_View_Helper_Placeholder_Registry
         $reflection = new ReflectionClass($name);
         if (!$reflection->isSubclassOf(new ReflectionClass('Zend_View_Helper_Placeholder_Container_Abstract'))) {
             require_once 'Zend/View/Helper/Placeholder/Registry/Exception.php';
-            throw new Zend_View_Helper_Placeholder_Registry_Exception('Invalid Container class specified');
+            $e = new Zend_View_Helper_Placeholder_Registry_Exception('Invalid Container class specified');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $this->_containerClass = $name;

+ 9 - 3
library/Zend/View/Helper/Translate.php

@@ -113,7 +113,9 @@ class Zend_View_Helper_Translate extends Zend_View_Helper_Abstract
             $this->_translator = $translate->getAdapter();
         } else {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
+            $e = new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $this;
@@ -148,7 +150,9 @@ class Zend_View_Helper_Translate extends Zend_View_Helper_Abstract
         $translate = $this->getTranslator();
         if ($translate === null) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
+            $e = new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
+            $e->setView($this->view);
+            throw $e;
         }
 
         $translate->setLocale($locale);
@@ -166,7 +170,9 @@ class Zend_View_Helper_Translate extends Zend_View_Helper_Abstract
         $translate = $this->getTranslator();
         if ($translate === null) {
             require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
+            $e = new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
+            $e->setView($this->view);
+            throw $e;
         }
 
         return $translate->getLocale();

+ 1 - 1
library/Zend/XmlRpc/Fault.php

@@ -203,7 +203,7 @@ class Zend_XmlRpc_Fault
         } catch (Exception $e) {
             // Not valid XML
             require_once 'Zend/XmlRpc/Exception.php';
-            throw new Zend_XmlRpc_Exception('Failed to parse XML fault: ' .  $e->getMessage(), 500);
+            throw new Zend_XmlRpc_Exception('Failed to parse XML fault: ' .  $e->getMessage(), 500, $e);
         }
 
         // Check for fault

+ 1 - 1
library/Zend/XmlRpc/Value.php

@@ -435,7 +435,7 @@ abstract class Zend_XmlRpc_Value
         } catch (Exception $e) {
             // The given string is not a valid XML
             require_once 'Zend/XmlRpc/Value/Exception.php';
-            throw new Zend_XmlRpc_Value_Exception('Failed to create XML-RPC value from XML string: ' . $e->getMessage(), $e->getCode());
+            throw new Zend_XmlRpc_Value_Exception('Failed to create XML-RPC value from XML string: ' . $e->getMessage(), $e->getCode(), $e);
         }
     }
 

+ 2 - 0
tests/Zend/AllTests.php

@@ -45,6 +45,7 @@ require_once 'Zend/CurrencyTest.php';
 require_once 'Zend/DateTest.php';
 require_once 'Zend/Date/AllTests.php';
 require_once 'Zend/DebugTest.php';
+require_once 'Zend/ExceptionTest.php';
 require_once 'Zend/Feed/AllTests.php';
 require_once 'Zend/File/AllTests.php';
 require_once 'Zend/FilterTest.php';
@@ -176,6 +177,7 @@ class Zend_AllTests
         $suite->addTest(Zend_Db_AllTests::suite());
         $suite->addTestSuite('Zend_DebugTest');
         $suite->addTest(Zend_Dom_AllTests::suite());
+        $suite->addTestSuite('Zend_ExceptionTest');
         $suite->addTest(Zend_Feed_AllTests::suite());
         $suite->addTest(Zend_File_AllTests::suite());
         $suite->addTestSuite('Zend_FilterTest');

+ 78 - 0
tests/Zend/ExceptionTest.php

@@ -0,0 +1,78 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Json
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+/**
+ * Test helper
+ */
+require_once dirname(__FILE__) . '/../TestHelper.php';
+
+/**
+ * @see Zend_Exception
+ */
+require_once 'Zend/Exception.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Exception
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_ExceptionTest extends PHPUnit_Framework_TestCase
+{
+    public function testConstructorDefaults()
+    {
+        $e = new Zend_Exception();
+        $this->assertEquals('', $e->getMessage());
+        $this->assertEquals(0, $e->getCode());
+        $this->assertNull($e->getPrevious());
+    }
+
+    public function testMessage()
+    {
+        $e = new Zend_Exception('msg');
+        $this->assertEquals('msg', $e->getMessage());
+    }
+
+    public function testCode()
+    {
+        $e = new Zend_Exception('msg', 100);
+        $this->assertEquals(100, $e->getCode());
+    }
+
+    public function testPrevious()
+    {
+        $p = new Zend_Exception('p', 0);
+        $e = new Zend_Exception('e', 0, $p);
+        $this->assertEquals($p, $e->getPrevious());
+    }
+
+    public function testToString()
+    {
+        $p = new Zend_Exception('p', 0);
+        $e = new Zend_Exception('e', 0, $p);
+        $s = $e->__toString();
+        $this->assertContains('p', $s);
+        $this->assertContains('Next', $s);
+        $this->assertContains('e', $s);
+    }
+}