File tree Expand file tree Collapse file tree
user_guide_src/source/general Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,18 +19,27 @@ Using Exceptions
1919
2020This 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+
2225Exceptions are simply events that happen when the exception is "thrown". This halts the current flow of the script, and
2326execution 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+
2733If 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
3137If the ``$userModel `` throws an exception, it is caught and the code within the catch block is executed. In this example,
3238the scripts dies, echoing the error message that the ``UserModel `` defined.
3339
40+ Catching Specific Exceptions
41+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
3443In the example above, we catch any type of Exception. If we only want to watch for specific types of exceptions, like
3544a ``UnknownFileException ``, we can specify that in the catch parameter. Any other exceptions that are thrown and are
3645not child classes of the caught exception will be passed on to the error handler:
You can’t perform that action at this time.
0 commit comments