Skip to content

Commit d447c7f

Browse files
committed
Sukreet | SHR-1216 | Throwing proper exceptions.
1 parent 71efab9 commit d447c7f

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

src/main/java/org/sharedhealth/datasense/client/FacilityWebClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ private String getResponse(String facilityId) throws URISyntaxException, IOExcep
7171
try {
7272
response = new WebClient().get(facilityUrl, headers);
7373
} catch (ConnectionException e) {
74-
log.error("Could not fetch facility");
74+
String message = "Could not fetch facility";
75+
log.error(message);
7576
if (e.getErrorCode() == 401)
7677
log.error("Unauthorized");
7778
}

src/main/java/org/sharedhealth/datasense/client/MciWebClient.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Patient identifyPatient(String healthId) throws URISyntaxException, IOExc
3838

3939
public String get(URI url) throws URISyntaxException, IOException {
4040
log.info("Reading from " + url);
41-
Map<String, String> headers = getHrmAccessTokenHeaders(identityServiceClient.getOrCreateToken(), properties);
41+
Map<String, String> headers = getHrmAccessTokenHeaders(identityServiceClient.getOrCreateToken(), properties);
4242
headers.put("Accept", "application/atom+xml");
4343
String response = null;
4444
try {
@@ -49,6 +49,7 @@ public String get(URI url) throws URISyntaxException, IOException {
4949
log.error("Unauthorized, clearing token.");
5050
identityServiceClient.clearToken();
5151
}
52+
throw new IOException("Could not fetch from url" + url, e);
5253
}
5354
return response;
5455
}
@@ -62,11 +63,13 @@ private String getResponse(final String healthId) throws URISyntaxException, IOE
6263
try {
6364
response = new WebClient().get(mciURI, headers);
6465
} catch (ConnectionException e) {
65-
log.error(String.format("Could not identify patient with healthId [%s]", healthId), e);
66+
String message = String.format("Could not identify patient with healthId [%s]", healthId);
67+
log.error(message, e);
6668
if (e.getErrorCode() == 401) {
6769
log.error("Unauthorized, clearing token.");
6870
identityServiceClient.clearToken();
6971
}
72+
throw new IOException(message, e);
7073
}
7174
return response;
7275
}

src/main/java/org/sharedhealth/datasense/client/ProviderWebClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ private String getResponse(String facilityId) throws URISyntaxException, IOExcep
5858
try {
5959
response = new WebClient().get(providerUrl, headers);
6060
} catch (ConnectionException e) {
61-
log.error("Could not fetch facility");
61+
String message = "Could not fetch provider";
62+
log.error(message);
6263
if (e.getErrorCode() == 401)
6364
log.error("Unauthorized.");
65+
throw new IOException(message);
6466
}
6567
return response;
6668
}

src/main/java/org/sharedhealth/datasense/client/ShrWebClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public String getEncounterFeedContent(URI uri) throws IOException {
3939
log.error("Unauthorized, clearing token.");
4040
identityServiceClient.clearToken();
4141
}
42-
throw new IOException(e);
43-
} catch (Exception e) {
4442
log.error(String.format("Could not fetch feed for URI [%s]", uri.toString()), e);
4543
throw new IOException(e);
4644
}

src/main/java/org/sharedhealth/datasense/client/TrWebClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public String getResponse(URI uri) throws IOException, URISyntaxException {
4747
String response;
4848
try {
4949
response = new WebClient().get(uri, headers);
50-
} catch (Exception e) {
50+
} catch (ConnectionException e) {
5151
log.error(String.format("Could not fetch feed for URI [%s] ", uri), e);
5252
throw new IOException(e);
5353
}

src/main/java/org/sharedhealth/datasense/feeds/patients/PatientUpdateEventWorker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void process(Event event) {
4444
patientDao.update(patientUpdate);
4545
} catch (Exception e) {
4646
logger.error(e.getMessage(), e);
47+
throw new RuntimeException(e.getMessage());
4748
}
4849
}
4950

0 commit comments

Comments
 (0)