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: README.md
+34-29Lines changed: 34 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -529,6 +529,12 @@ title.sample.problem=Some title
529
529
detail.sample.problem=Some message details
530
530
```
531
531
532
+
> [!WARNING]
533
+
> It uses Spring's `MessageSource` to resolve placeholders in message template.
534
+
> You should be aware that the single quote character (') fulfils a special purpose inside message patterns.
535
+
> The single quote is used to represent a section within the message pattern that will not be formatted.
536
+
> A single quote itself must be escaped by using two single quotes ('').
537
+
532
538
But exceptions come with some default attributes as follows, to minimize the number of properties required to be defined in `properties` file
533
539
534
540
If the messages are not found in `properties` files, defaults are taken as follows.
@@ -741,43 +747,42 @@ class CustomErrorResponseBuilder implements ErrorResponseBuilder<ServerWebExchan
741
747
Any autoconfigured advice can be customized by overriding the same and providing a different implementation.
742
748
Make sure to add annotation `@Order(Ordered.HIGHEST_PRECEDENCE)` over the class,
743
749
It makes this handler to take precedence over the fallback advice which handles `Throwable` i.e. for all exceptions for which no `ControllerAdvice`s are defined.
750
+
In case of Constraint Violation exceptions, the `errorKey` is derived from the field name,
751
+
but in cases where field name is customized using `@JsonProperty`,
752
+
`MethodArgumentNotValidException` may need to be customized to use `@JsonProperty` instead of class's field name in dynamically generated `erroKey` as follows
744
753
745
754
> For Spring Web applications
746
755
```java
747
756
@ControllerAdvice
748
757
@Order(Ordered.HIGHEST_PRECEDENCE) // Important to note
0 commit comments