Skip to content

Commit

Permalink
handle missing error code (0 as default)
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Jan 23, 2025
1 parent 5e09340 commit e427dfb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/com/contentstack/sdk/CSHttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,14 @@ void setError(String 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));

int errCode = 0;
try {
errCode = Integer.parseInt(responseJSON.optString(ERROR_CODE));
} catch (NumberFormatException e) {
// in case of missing error code, we keep it 0
}

connectionRequest.onRequestFailed(responseJSON, errCode, callBackObject);
}

Expand Down

0 comments on commit e427dfb

Please sign in to comment.