Skip to content

Commit 50eafce

Browse files
committed
docs: add sub section titles
1 parent 67fa536 commit 50eafce

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

user_guide_src/source/general/errors.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,27 @@ Using Exceptions
1919

2020
This section is a quick overview for newer programmers, or for developers who are not experienced with using exceptions.
2121

22+
What is Exceptions
23+
------------------
24+
2225
Exceptions are simply events that happen when the exception is "thrown". This halts the current flow of the script, and
2326
execution is then sent to the error handler which displays the appropriate error page:
2427

2528
.. literalinclude:: errors/001.php
2629

30+
Catching Exceptions
31+
-------------------
32+
2733
If you are calling a method that might throw an exception, you can catch that exception using a ``try/catch`` block:
2834

2935
.. literalinclude:: errors/002.php
3036

3137
If the ``$userModel`` throws an exception, it is caught and the code within the catch block is executed. In this example,
3238
the scripts dies, echoing the error message that the ``UserModel`` defined.
3339

40+
Catching Specific Exceptions
41+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
3443
In the example above, we catch any type of Exception. If we only want to watch for specific types of exceptions, like
3544
a ``UnknownFileException``, we can specify that in the catch parameter. Any other exceptions that are thrown and are
3645
not child classes of the caught exception will be passed on to the error handler:

0 commit comments

Comments
 (0)