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

java.lang.NumberFormatException: For input string: "" exception is triggered for some errors as timeouts #161

Closed
goetas opened this issue Jan 21, 2025 · 3 comments

Comments

@goetas
Copy link

goetas commented Jan 21, 2025

In this part of the code

try {
responseJSON = new JSONObject(errResp);
} catch (JSONException e) {
// If errResp is not valid JSON, create a new JSONObject with the error message
responseJSON = new JSONObject();
responseJSON.put(ERROR_MESSAGE, errResp);
}
responseJSON.put(ERROR_MESSAGE, responseJSON.optString(ERROR_MESSAGE));
responseJSON.put(ERROR_CODE, responseJSON.optString(ERROR_CODE));
responseJSON.put(ERRORS, responseJSON.optString(ERRORS));
int errCode = Integer.parseInt(responseJSON.optString(ERROR_CODE));

when there is an JSONException, a "fake" JSONObject is created. That object does not contain an error code.

later when int errCode = Integer.parseInt(responseJSON.optString(ERROR_CODE)); is executed an java.lang.NumberFormatException: For input string: "" exception is triggered.

@goetas
Copy link
Author

goetas commented Jan 23, 2025

I have created #163 to fix the issue

@reeshika-h
Copy link
Contributor

Hey @goetas thank you for the suggestion, will review your PR.

This was referenced Feb 26, 2025
@reeshika-h
Copy link
Contributor

Hey @goetas , v2.0.3 has been released. Please let us know if you face any further queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants