Skip to content

Commit

Permalink
Better error handling when linkHqWorker fails
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeAndGreen committed Dec 4, 2024
1 parent 906137d commit a8bcc43
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/src/org/commcare/connect/network/ApiConnectId.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ public static void linkHqWorker(Context context, String hqUsername, ConnectLinke
try {
ConnectNetworkHelper.PostResult postResult = ConnectNetworkHelper.postSync(context, url,
API_VERSION_NONE, new AuthInfo.ProvidedAuth(hqUsername, appRecord.getPassword()), params, true, false);
if (postResult.e == null && postResult.responseCode == 200) {
if(postResult.e != null) {
Logger.exception("Network error linking HQ worker", postResult.e);
} else if (postResult.responseCode == 200) {
postResult.responseStream.close();

//Remember that we linked the user successfully
appRecord.setWorkerLinked(true);
ConnectDatabaseHelper.storeApp(context, appRecord);
} else {
Logger.log("API Error", "API call to link HQ worker failed with code " + postResult.responseCode);
}
} catch (IOException e) {
//Don't care for now
Logger.exception("Error linking HQ worker", e);
}
}

Expand Down

0 comments on commit a8bcc43

Please sign in to comment.