1

I have config the spring cloud gateway hystrix as below:

default-filters:
-   name: Hystrix
    args:
        name: defaultGatewayCommand
        fallbackUri: forward:/hystrix-fallback

The problem is, for example, when I throw ResponseStatusException exception in my project, the hystrix fallback will be triggered.

@GetMapping("/hystrix-fallback")
public Mono<ApiErrorResponse> hystrixFallback() {
    return Mono.just(new ApiErrorResponse("xxxxxxxx"));
}

I want to catch some error info and build my new ApiErrorResponse, but i don 't how to do it?

steven.tong
  • 345
  • 3
  • 16

1 Answers1

0

@GetMapping("/hystrix-fallback") public Mono hystrixFallback(ServerWebExchange exchange) { Exception exception = exchange.getAttribute(ServerWebExchangeUtils.HYSTRIX_EXECUTION_EXCEPTION_ATTR); return Mono.just(new ApiErrorResponse("xxxxxxxx")); }

huang
  • 11