micronaut-core
micronaut-core copied to clipboard
Implement http-client error log for non-CompletableFuture responses
Discussed in https://github.com/micronaut-projects/micronaut-core/discussions/10551
Originally posted by stefanos-kalantzis February 27, 2024 Case in point: https://github.com/micronaut-projects/micronaut-core/blob/3fc45e7e70982cd1b9ef104c03053246e70ce2c5/http-client-core/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java#L384
Hello, I am new to micronaut-core and I would like to work on this issue. Is it still open?
yes. go ahead.
Cool, Thanks! So, the http-client error log is already there for the case of COMPLETION_STAGE. And for the PUBLISHER case, the subscribers will be responsible to add the required logs in doOnError.
To add the similar log for the SYNCHRONOUS case, we can just wrap the code performing the blocking calls with try/catch, log the error and re-throw the exception to be handled by the outer catch block to centralize the error handling for all 3 cases.
Am I right? I am so sorry if the question sounds silly. Just want to make sure I understand the requirement correctly. Thank you in advance! :smile:
that seems sensible for the sync case. I think it is also worthwhile to add the doOnError you mention on our own, just like it's implemented for CompletableFuture.
Thank you for the confirmation and the suggestion @yawkat. I'll get right to it.