Skip to content

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

Closed

Description

@goetas

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.

Activity

  1. goetas commented on Jan 23, 2025

    @goetas
    Author

    I have created #163 to fix the issue

  2. reeshika-h commented on Jan 30, 2025

    @reeshika-h
    Contributor

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

  3. reeshika-h commented on Mar 4, 2025

    @reeshika-h
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions