File: Zend_Exception.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (47 lines) | stat: -rw-r--r-- 1,605 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?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:
-->