micronaut-core icon indicating copy to clipboard operation
micronaut-core copied to clipboard

Implement http-client error log for non-CompletableFuture responses

Open yawkat opened this issue 1 year ago • 5 comments

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

yawkat avatar Mar 07 '24 13:03 yawkat

Hello, I am new to micronaut-core and I would like to work on this issue. Is it still open?

meetpatel0963 avatar Mar 23 '24 20:03 meetpatel0963

yes. go ahead.

yawkat avatar Mar 25 '24 08:03 yawkat

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:

meetpatel0963 avatar Mar 26 '24 13:03 meetpatel0963

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.

yawkat avatar Mar 26 '24 14:03 yawkat

Thank you for the confirmation and the suggestion @yawkat. I'll get right to it.

meetpatel0963 avatar Mar 27 '24 18:03 meetpatel0963