Skip to content

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

@goetas

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.

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