-
-
Notifications
You must be signed in to change notification settings - Fork 747
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
Support returning api response in case of deserialization exception #1167
Support returning api response in case of deserialization exception #1167
Conversation
…return type is ApiResponse
…andle deserializations directly, and non ApiResponse to throw
…erialization_exception
Also @clairernovotny I noticed while putting this together that ApiResponse doesn't seem to support ValidationApiException either... I didn't finish going all the way down the rabbit hole of why but it seems related to it being a subclass of ApiException. I would somewhat prefer a design whereby the details that ValidationApiException exposes live as an inner exception inside of ApiException as having two top-level exceptions here means more try/catch and IMO violates the principle of least surprise. Thoughts? |
…esponse<T>> and Task<T>
…n_exception' of https://github.com/james-s-tayler/refit into support_returning_ApiResponse_in_case_of_deserialization_exception
…erialization_exception
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What kind of change does this PR introduce?
This is a bug fix for #1160 and #1017 - ApiResponse wasn't trapping exceptions that occurred while attempting to deserialize the response, which violated the expectations of the ApiResponse programming model.
What is the current behavior?
The current behavior is that an ApiResponse will throw a Refit.ApiException if an exception is thrown while attempting to deserialize the response.
What is the new behavior?
The deserialization exception is properly wrapped by a Refit.ApiException and returned in the ApiResponse
What might this PR break?
I've added tests for this and ensured the existing tests for the non ApiResponse case still pass. If callers knew about the current behavior and had explicit try/catch blocks those will no longer be invoked anymore. Though, all callers will almost certainly have existing exception handling logic for the ApiResponse which should pick up the deserialization exceptions now too. I, for one, didn't realize the library behaved as it does at present and expected every and all exception to come back via ApiResponse.Error.
Please check if the PR fulfills these requirements