Zend_Exception.xml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 15103 -->
  3. <!-- Reviewed: no -->
  4. <!-- Traducir todo de nuevo-->
  5. <sect1 id="zend.exception.using">
  6. <title>Using Exceptions</title>
  7. <para>
  8. <classname>Zend_Exception</classname> is simply the base class for all
  9. exceptions thrown within Zend Framework. </para>
  10. <example id="zend.exception.using.example">
  11. <title>Catching an Exception</title>
  12. <para> The following code listing demonstrates how to catch an exception
  13. thrown in a Zend Framework class: </para>
  14. <programlisting language="php"><![CDATA[
  15. try {
  16. // Calling Zend_Loader::loadClass() with a non-existant class will cause
  17. // an exception to be thrown in Zend_Loader
  18. Zend_Loader::loadClass('nonexistantclass');
  19. } catch (Zend_Exception $e) {
  20. echo "Caught exception: " . get_class($e) . "\n";
  21. echo "Message: " . $e->getMessage() . "\n";
  22. // Other code to recover from the error
  23. }
  24. ]]></programlisting>
  25. </example>
  26. <para>
  27. <classname>Zend_Exception</classname> can be used as a catch-all
  28. exception class in a catch block to trap all exceptions thrown by Zend
  29. Framework classes. This can be useful when the program can not recover
  30. by catching a specific exception type. </para>
  31. <para> The documentation for each Zend Framework component and class will
  32. contain specific information on which methods throw exceptions, the
  33. circumstances that cause an exception to be thrown, and the class of all
  34. exceptions that may be thrown. </para>
  35. </sect1>