db0e68d0fbb0f1666664cfdf46119b6bc05f41e2
[GitHub/WoltLab/woltlab.github.io.git] / docs / php / exceptions.md
1 # Exceptions
2
3 ## SPL Exceptions
4
5 The [Standard PHP Library (SPL)](https://secure.php.net/manual/en/book.spl.php) provides some [exceptions](https://secure.php.net/manual/en/spl.exceptions.php) that should be used whenever possible.
6
7
8 ## Custom Exceptions
9
10 !!! warning "Do not use `wcf\system\exception\SystemException` anymore, use specific exception classes!"
11
12 The following table contains a list of custom exceptions that are commonly used.
13 All of the exceptions are found in the `wcf\system\exception` namespace.
14
15 | Class name | (examples) when to use |
16 |-----------|------------------------|
17 | `IllegalLinkException` | access to a page that belongs to a non-existing object, executing actions on specific non-existing objects (is shown as http 404 error to the user) |
18 | `ImplementationException` | a class does not implement an expected interface |
19 | `InvalidObjectArgument` | <span class="label label-info">5.4+</span> API method support generic objects but specific implementation requires objects of specific (sub)class and different object is given |
20 | `InvalidObjectTypeException` | object type is not of an expected object type definition |
21 | `InvalidSecurityTokenException` | given security token does not match the security token of the active user's session |
22 | `ParentClassException` | a class does not extend an expected (parent) class |
23 | `PermissionDeniedException` | page access without permission, action execution without permission (is shown as http 403 error to the user) |
24 | `UserInputException` | user input does not pass validation |