<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.exception.using">
    <title>Using Exceptions</title>

    <para>
        <classname>Zend_Exception</classname> is simply the base class for all exceptions thrown
        within Zend Framework.
    </para>

    <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:
    Zend_Loader::loadClass('nonexistantclass');
} catch (Zend_Exception $e) {
    echo "Caught exception: " . get_class($e) . "\n";
    echo "Message: " . $e->getMessage() . "\n";
    // Other code to recover from the error
}
]]></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
        be useful when the program can not recover by catching a specific exception type.
    </para>

    <para>
        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 various exception types that may be thrown.
    </para>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->
