File tree 1 file changed +30
-0
lines changed
spring-boot-reactive-full-example/src/main/java/me/jittagornp/example/reactive/error/handler
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2017-2019 Pamarin.com
3
+ */
4
+ package me .jittagornp .example .reactive .error .handler ;
5
+
6
+ import me .jittagornp .example .reactive .error .ErrorResponse ;
7
+ import me .jittagornp .example .reactive .error .ErrorResponseExceptionHandlerAdapter ;
8
+ import me .jittagornp .example .reactive .exception .InvalidRequestException ;
9
+ import org .springframework .stereotype .Component ;
10
+ import org .springframework .web .server .ServerWebExchange ;
11
+ import reactor .core .publisher .Mono ;
12
+
13
+ /**
14
+ * @author jitta
15
+ */
16
+ @ Component
17
+ public class ErrorResponseInvalidRequestExceptionHandler extends ErrorResponseExceptionHandlerAdapter <InvalidRequestException > {
18
+
19
+ @ Override
20
+ public Class <InvalidRequestException > getTypeClass () {
21
+ return InvalidRequestException .class ;
22
+ }
23
+
24
+ @ Override
25
+ protected Mono <ErrorResponse > buildError (final ServerWebExchange exchange , final InvalidRequestException e ) {
26
+ return Mono .fromCallable (() -> {
27
+ return ErrorResponse .invalidRequest (e .getMessage ());
28
+ });
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments