2

new to Micronaut and am wondering how people are handling errors. The example in the documentation uses blocking which I do not want to use to handle errors. Basically, what i'd like to do is be able to detect if error and if so, convert it to Errors class. If it can't convert to Errors class, let a global handler handle it. Does anyone have good sample code for my scenario? Below is my code. Thank you

@Client(value = "${my.host}", errorType = Errors.class)
@Header(name = "ClientId", value = "${clientId}")
@JacksonFeatures(enabledDeserializationFeatures = UNWRAP_ROOT_VALUE,
    disabledDeserializationFeatures = FAIL_ON_UNKNOWN_PROPERTIES)
public interface MyClient {

    @Get("/myurl/{?queryParams*}")
    public Single<MyResult> search(@Nullable @QueryValue Map<String, Object> queryParams);

}
Ricardo Riveros
  • 233
  • 3
  • 11

1 Answers1

0

You can define your own ExceptionHandler (§6.17.4: https://docs.micronaut.io/latest/guide/#exceptionHandler) that handles HttpClientResponseException, see also Error Responses (§7.3.6: https://docs.micronaut.io/latest/guide/#lowLevelClientError)