Open drewburlingame opened 4 months ago
Thanks for this.
I wonder if a better way to build this in at some point would be to add some APIs related to introspection (which would maybe fit with some one-day aim to improve logging/debugging), and then something like this could build on top of that.
This is definitely a hack and there are better ways to provide this if done from within the framework. Providing this level of detail is also probably not necessary for all consumers of the package. I could see making it an option and/or lazily resolved property on the exception.
When first using this library, we found it difficult to debug issues when a registration wasn't found that we expected. We use Refit and found that sometimes the mismatch was due to order of url params or encoding issues. We also have test infra to configure common calls like auth sequences for various integrations.
We ended up extending IntereceptingHttpMessageHandler to enrich the HttpRequestNotInterceptedException with a list of registered interceptions. Below is the handler we created. It's not perfect since it can't easily report custom matching, but it significantly improved our experience of troubleshooting missing registrations. I've been intending to offer this as a PR but I don't think I'll have time soon so wanted to offer this for anyone it might benefit or would like to use for a PR.