|
@@ -19,33 +19,25 @@ import reactor.core.publisher.Mono;
|
|
*/
|
|
*/
|
|
@Order(-1)
|
|
@Order(-1)
|
|
@Configuration
|
|
@Configuration
|
|
-public class GatewayExceptionHandler implements ErrorWebExceptionHandler
|
|
|
|
-{
|
|
|
|
|
|
+public class GatewayExceptionHandler implements ErrorWebExceptionHandler {
|
|
private static final Logger log = LoggerFactory.getLogger(GatewayExceptionHandler.class);
|
|
private static final Logger log = LoggerFactory.getLogger(GatewayExceptionHandler.class);
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Mono<Void> handle(ServerWebExchange exchange, Throwable ex)
|
|
|
|
- {
|
|
|
|
|
|
+ public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
|
|
ServerHttpResponse response = exchange.getResponse();
|
|
ServerHttpResponse response = exchange.getResponse();
|
|
|
|
|
|
- if (exchange.getResponse().isCommitted())
|
|
|
|
- {
|
|
|
|
|
|
+ if (exchange.getResponse().isCommitted()) {
|
|
return Mono.error(ex);
|
|
return Mono.error(ex);
|
|
}
|
|
}
|
|
|
|
|
|
String msg;
|
|
String msg;
|
|
|
|
|
|
- if (ex instanceof NotFoundException)
|
|
|
|
- {
|
|
|
|
|
|
+ if (ex instanceof NotFoundException) {
|
|
msg = "服务未找到";
|
|
msg = "服务未找到";
|
|
- }
|
|
|
|
- else if (ex instanceof ResponseStatusException)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (ex instanceof ResponseStatusException) {
|
|
ResponseStatusException responseStatusException = (ResponseStatusException) ex;
|
|
ResponseStatusException responseStatusException = (ResponseStatusException) ex;
|
|
msg = responseStatusException.getMessage();
|
|
msg = responseStatusException.getMessage();
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
msg = "内部服务器错误";
|
|
msg = "内部服务器错误";
|
|
}
|
|
}
|
|
|
|
|