Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content in ValidationApiException hides Content in derived ApiException #636

Closed
SWarnberg opened this issue Mar 15, 2019 · 5 comments · Fixed by #953
Closed

Content in ValidationApiException hides Content in derived ApiException #636

SWarnberg opened this issue Mar 15, 2019 · 5 comments · Fixed by #953
Assignees

Comments

@SWarnberg
Copy link

Hi

I think it's a bad design to hide the Content property of the derived class ApiException. The reason is that if you don't catch ValidationApiException but catch ApiException, you expect to get the Content property as string. However, if the real content is a problem+json document, it's null in the ApiException.
A better approach would be to have a new property in the ValidationApiException class that returns the ProblemDetails and keep Content as text, giving the client a chance to deserialize the problem itself.

Staffan

@DrakeLambert
Copy link
Contributor

I'm having this exact issue right now. Took me 30 minutes to finally track down this issue.

@jamiehowarth0
Copy link
Member

It's because the request object is disposed when catching the exception. I'll look at how to do this in a better fashion.

@jamiehowarth0 jamiehowarth0 self-assigned this Jan 11, 2020
DrakeLambert added a commit to DrakeLambert/refit that referenced this issue Jul 31, 2020
@DrakeLambert
Copy link
Contributor

@jamiehowarth0 See my PR!

@winterdouglas
Copy link

I'm facing this exact same issue.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants