Zend_Exception.xml 1.5 KB

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