File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -32,43 +32,45 @@ Maven
3232
3333## Usage
3434
35- Import
35+ Import error methods
3636
3737``` java
3838import 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
4445throw notFound();
4546throw badRequest(" id required." );
4647throw internalServerError(exception);
48+ // ...
4749```
4850
4951Assign
5052
5153``` shell
52- AbstractApiError error = unauthorized ();
54+ ApiError error = unauthorized ();
5355```
5456
5557See [ 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```
6264ApiError.creator(ApiErrorCreators.BASIC); // The default
6365ApiError.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```
You can’t perform that action at this time.
0 commit comments