Skip to content

Commit e90c0a2

Browse files
committed
linting
Signed-off-by: alexmerlin <[email protected]>
1 parent d3eb894 commit e90c0a2

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

docs/book/v4/core-features/exceptions.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,43 @@ They provide a way to manage errors in a structured and controlled manner, separ
1010
When it comes to handling exceptions, DotKernel API relies on the usage of easy-to-understand, problem-specific exceptions.
1111

1212
Ou-of-the-box we provide the following custom exceptions:
13+
1314
* `BadRequestException` thrown when:
14-
* client tries to create/update resource, but the data from the request is invalid/incomplete (example: client tries to create an account, but does not send the required `identity` field)
15+
16+
1. client tries to create/update resource, but the data from the request is invalid/incomplete (example: client tries to create an account, but does not send the required `identity` field)
17+
1518
* `ConflictException` thrown when:
16-
* resource cannot be created because a different resource with the same identifier already exists (example: cannot change existing user's identity because another user with the same identity already exists)
17-
* resource cannot change its state because it is already in the specified state (example: user cannot be activated because it is already active)
19+
20+
1. resource cannot be created because a different resource with the same identifier already exists (example: cannot change existing user's identity because another user with the same identity already exists)
21+
2. resource cannot change its state because it is already in the specified state (example: user cannot be activated because it is already active)
22+
1823
* `ExpiredException` thrown when:
19-
* resource cannot be accessed because it expired (example: account activation link)
20-
* resource cannot be accessed because it has been consumed (example: one-time password)
24+
25+
1. resource cannot be accessed because it expired (example: account activation link)
26+
2. resource cannot be accessed because it has been consumed (example: one-time password)
27+
2128
* `ForbiddenException` thrown when:
22-
* resource cannot be accessed by the authenticated client (example: client authenticated as regular user sends a `GET /admin` request)
29+
30+
1. resource cannot be accessed by the authenticated client (example: client authenticated as regular user sends a `GET /admin` request)
31+
2332
* `MethodNotAllowedException` thrown when:
24-
* client tries to interact with a resource via an invalid HTTP request method (example: client sends a `PATCH /avatar` request)
33+
34+
1. client tries to interact with a resource via an invalid HTTP request method (example: client sends a `PATCH /avatar` request)
35+
2536
* `NotFoundException` thrown when:
26-
* client tries to interact with a resource that does not exist on the server (example: client sends a `GET /resource-does-not-exist` request)
37+
38+
1. client tries to interact with a resource that does not exist on the server (example: client sends a `GET /resource-does-not-exist` request)
39+
2740
* `UnauthorizedException` thrown when:
28-
* resource cannot be accessed because the client is not authenticated (example: unauthenticated client sends a `GET /admin` request)
41+
42+
1. resource cannot be accessed because the client is not authenticated (example: unauthenticated client sends a `GET /admin` request)
2943

3044
## How it works?
3145

3246
During a request, if there is no uncaught exception DotKernel API will return a JSON response with the data provided by the handler that handled the request.
3347

3448
Else, it will build and send a response based on the exception thrown:
49+
3550
* `BadRequestException` will return a `400 Bad Request` response
3651
* `UnauthorizedException` will return a `401 Unauthorized` response
3752
* `ForbiddenException` will return a `403 Forbidden` response
@@ -63,6 +78,7 @@ class CustomException extends Exception
6378
{
6479
}
6580
```
81+
6682
Save and close the file.
6783

6884
### Step 2: Use exception file
@@ -72,6 +88,7 @@ Open the file `src/App/src/Handler/HomeHandler.php` and at the beginning of the
7288
```php
7389
throw new \Api\App\Exception\CustomException('some message');
7490
```
91+
7592
Save and close the file.
7693

7794
### Step 3: Test for failure

0 commit comments

Comments
 (0)