Skip to content

Commit 0d68190

Browse files
committed
docs: use real Exception class in sample code
1 parent 50eafce commit 0d68190

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

user_guide_src/source/general/errors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Catching Specific Exceptions
4141
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4242

4343
In the example above, we catch any type of Exception. If we only want to watch for specific types of exceptions, like
44-
a ``UnknownFileException``, we can specify that in the catch parameter. Any other exceptions that are thrown and are
44+
a ``DataException``, we can specify that in the catch parameter. Any other exceptions that are thrown and are
4545
not child classes of the caught exception will be passed on to the error handler:
4646

4747
.. literalinclude:: errors/003.php
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22

3+
use CodeIgniter\Database\Exceptions\DataException;
4+
35
try {
46
$user = $userModel->find($id);
5-
} catch (\CodeIgniter\UnknownFileException $e) {
7+
} catch (DataException $e) {
68
// do something here...
79
}

user_guide_src/source/general/errors/004.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

3+
use CodeIgniter\Database\Exceptions\DataException;
4+
35
try {
46
$user = $userModel->find($id);
5-
} catch (\CodeIgniter\UnknownFileException $e) {
7+
} catch (DataException $e) {
68
// do something here...
79

810
throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);

0 commit comments

Comments
 (0)