1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.exception.using">
4 <title>Using Exceptions</title>
7 <classname>Zend_Exception</classname> is simply the base class for all exceptions thrown
11 <example id="zend.exception.using.example">
12 <title>Catching an Exception</title>
15 The following code listing demonstrates how to catch an exception thrown in a Zend
19 <programlisting language="php"><![CDATA[
21 // Calling Zend_Loader::loadClass() with a non-existant class will cause
22 // an exception to be thrown in Zend_Loader:
23 Zend_Loader::loadClass('nonexistantclass');
24 } catch (Zend_Exception $e) {
25 echo "Caught exception: " . get_class($e) . "\n";
26 echo "Message: " . $e->getMessage() . "\n";
27 // Other code to recover from the error
33 <classname>Zend_Exception</classname> can be used as a catch-all exception class in a
34 catch block to trap all exceptions thrown by Zend Framework classes. This can
35 be useful when the program can not recover by catching a specific exception type.
39 The documentation for each Zend Framework
40 component and class will contain specific information on which methods
41 throw exceptions, the circumstances that cause an exception to be thrown,
42 and the various exception types that may be thrown.