You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/book/v4/core-features/exceptions.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,43 +7,43 @@ They provide a way to manage errors in a structured and controlled manner, separ
7
7
8
8
## How we use exceptions?
9
9
10
-
When it comes to handling exceptions, DotKernel API relies on the usage of easy-to-understand, problem-specific exceptions.
10
+
When it comes to handling exceptions, **DotKernel API** relies on the usage of easy-to-understand, problem-specific exceptions.
11
11
12
-
Ou-of-the-box we provide the following custom exceptions:
12
+
Out-of-the-box we provide the following custom exceptions:
13
13
14
-
*`BadRequestException` thrown when:
14
+
###`BadRequestException` thrown when:
15
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)
16
+
* 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
+
18
+
### `ConflictException` thrown when:
17
19
18
-
*`ConflictException` thrown when:
20
+
* 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
+
* resource cannot change its state because it is already in the specified state (example: user cannot be activated because it is already active)
19
22
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)
23
+
### `ExpiredException` thrown when:
22
24
23
-
*`ExpiredException` thrown when:
25
+
* resource cannot be accessed because it expired (example: account activation link)
26
+
* resource cannot be accessed because it has been consumed (example: one-time password)
24
27
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)
28
+
### `ForbiddenException` thrown when:
27
29
28
-
*`ForbiddenException` thrown when:
30
+
*resource cannot be accessed by the authenticated client (example: client authenticated as regular user sends a `GET /admin` request)
29
31
30
-
1. resource cannot be accessed by the authenticated client (example: client authenticated as regular user sends a `GET /admin` request)
32
+
### `MethodNotAllowedException` thrown when:
31
33
32
-
*`MethodNotAllowedException` thrown when:
34
+
*client tries to interact with a resource via an invalid HTTP request method (example: client sends a `PATCH /avatar` request)
33
35
34
-
1. client tries to interact with a resource via an invalid HTTP request method (example: client sends a `PATCH /avatar` request)
36
+
### `NotFoundException` thrown when:
35
37
36
-
*`NotFoundException` thrown when:
38
+
*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
39
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)
40
+
### `UnauthorizedException` thrown when:
39
41
40
-
*`UnauthorizedException` thrown when:
41
-
42
-
1. resource cannot be accessed because the client is not authenticated (example: unauthenticated client sends a `GET /admin` request)
42
+
* resource cannot be accessed because the client is not authenticated (example: unauthenticated client sends a `GET /admin` request)
43
43
44
44
## How it works?
45
45
46
-
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.
46
+
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.
47
47
48
48
Else, it will build and send a response based on the exception thrown:
0 commit comments