Skip to content

Commit a2712a0

Browse files
author
Carmine DiMascio
committed
2 parents 198c69f + e716f54 commit a2712a0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,45 @@ Maven
3232

3333
## Usage
3434

35-
Import
35+
Import error methods
3636

3737
```java
3838
import static io.github.cdimascio.japierrors.ApiError.badRequest;
39+
// ...
3940
```
4041

41-
Throw
42+
Throw any HTTP error and optionally pass an exception or custom message.
4243

4344
```java
4445
throw notFound();
4546
throw badRequest("id required.");
4647
throw internalServerError(exception);
48+
// ...
4749
```
4850

4951
Assign
5052

5153
```shell
52-
AbstractApiError error = unauthorized();
54+
ApiError error = unauthorized();
5355
```
5456

5557
See [examples](#examples) with Spring MVC
5658

5759
## Configure
5860

59-
japi-errors supports two error formats "out of the box". They are enabled as follows:
61+
**japi-errors** supports two error formats "out of the box". They are enabled as follows:
6062

6163
```
6264
ApiError.creator(ApiErrorCreators.BASIC); // The default
6365
ApiError.creator(ApiErrorCreators.WCP);
6466
```
6567

66-
### Basic
68+
### Basic (default)
6769

6870
```json
6971
{
7072
"code": 400,
71-
"error": "'id' required."
73+
"error": "id required."
7274
}
7375
```
7476

@@ -79,7 +81,7 @@ ApiError.creator(ApiErrorCreators.WCP);
7981
"trace": "1f96a430-dfd8-11e8-9f32-f2801f1b9fd1",
8082
"errors": [{
8183
"code": "bad_request",
82-
"message": "'id' required."
84+
"message": "id required."
8385
}]
8486
}
8587
```

0 commit comments

Comments
 (0)