reference/errorfunc/functions/set-exception-handler.xml
4a6671fe697ead5b27603b56face01a2c4e7ebe5
4a6671fe697ead5b27603b56face01a2c4e7ebe5
...
...
@@ -30,9 +30,10 @@
30
30
<listitem>
31
31
<para>
32
32
The function to be called when an uncaught exception occurs.
33
-
Most errors are reported by throwing <classname>Error</classname>
34
-
exceptions, which will be caught by the handler as well. Both <classname>Error</classname>
35
-
and <classname>Exception</classname> implements the <classname>Throwable</classname> interface.
33
+
This handler function needs to accept one parameter,
34
+
which will be the <classname>Throwable</classname> object that was thrown.
35
+
Both <classname>Error</classname> and <classname>Exception</classname>
36
+
implement the <classname>Throwable</classname> interface.
36
37
This is the handler signature:
37
38
</para>
38
39
<para>
...
...
@@ -66,7 +67,7 @@
66
67
<programlisting role="php">
67
68
<![CDATA[
68
69
<?php
69
-
function exception_handler($exception) {
70
+
function exception_handler(Throwable $exception) {
70
71
echo "Uncaught exception: " , $exception->getMessage(), "\n";
71
72
}
72
73
...
...
@@ -85,10 +86,11 @@ echo "Not Executed\n";
85
86
&reftitle.seealso;
86
87
<para>
87
88
<simplelist>
89
+
<member><function>get_exception_handler</function></member>
88
90
<member><function>restore_exception_handler</function></member>
89
91
<member><function>restore_error_handler</function></member>
90
92
<member><function>error_reporting</function></member>
91
-
<member><link linkend="language.exceptions">PHP 5 Exceptions</link></member>
93
+
<member><link linkend="language.exceptions">Exceptions</link></member>
92
94
</simplelist>
93
95
</para>
94
96
</refsect1><!-- }}} -->
95
97