tmenier / Flurl

Fluent URL builder and testable HTTP client for .NET
https://flurl.dev
MIT License
4.23k stars 387 forks source link

OnErrorAsync is not recognizing FlurlHttpTimeoutException #720

Closed es1anjlsanchez closed 2 years ago

es1anjlsanchez commented 2 years ago

We have a OnErrorAsync subscribed in every FlurlRequest. Now, I have explicitly changed the timeout to 0 in order for me to build a specific log message for timeouts. However, the object is not returning a flurlexception, but looks to be a HttpCall object only.

image

I tried to capture it in the code as well but no luck.

image

Interestengly, if we put a try catch specifically for FlurlHttpTimeoutException, it gives the object that I was hoping to get.

image

May I ask for the possible reason because I can not get any. Thanks a lot.

tmenier commented 2 years ago

The only thing I'm noticing in what you provided is that in your second screenshot, a FlurlHttpTimeoutException would get caught in the first "if" condition, because FlurlHttpTimeoutException inherits from FlurlHttpException, hence it "is" a FlurlHttpException. I'm not sure if that's what you're saying is happening though. I don't think you posted enough code here to demonstrate a bug. Please show the minimal code to reproduce. And if this is not a bug but a programming question, I would encourage you to ask on Stack Overflow.

tmenier commented 2 years ago

Can't repro the bug as I understand it and haven't heard back with any clarifications, so closing this. Again if this is more of a programming question than I bug, please ask on Stack Overflow.