-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: Catch JSONException from parsing vardata response #33
Conversation
} | ||
} catch (e: JSONException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should catch this exception from the place where parseResponse is called rather than inside this function. Line 238. Then we can call the onFailure
function to complete the future exceptionally and propagate the error more clearly.
when (e) { | ||
is IOException -> onFailure(call, e) | ||
is JSONException -> future.completeExceptionally(e) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onFailure is the same as calling completeExceptionally, so we should just maintain consistency. Further, this logic would ignore all other errors, which is not ideal. Either we (a) catch and propagate all exceptions or (b) only catch and propagate some exceptions, leavin some to be thrown in the callback.
I think we go with (a) so we can just do catch any exception and pass it to onFailure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this, the onFailure function in the Callback interface has signature fun onFailure(call: Call, e: IOException)
, should I create an onFailure function which takes in any exception type then?
## [1.10.1](1.10.0...1.10.1) (2023-09-26) ### Bug Fixes * Catch JSONException from parsing vardata response ([#33](#33)) ([cabbb5d](cabbb5d))
🎉 This PR is included in version 1.10.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
No description provided.