Skip to content

Commit 9be64f6

Browse files
committed
Always return valid json if elasticsearch is missing
1 parent 7d20f55 commit 9be64f6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

cws-service/src/main/java/jpl/cws/controller/RestService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,14 +837,14 @@ public ModelAndView validateAndSaveSnippets(
837837
restCallResult = WebUtils.restCall(urlString, "GET", null, null, null, "application/json; charset=utf-8");
838838
}
839839
if (restCallResult.getResponseCode() != 200) {
840-
return "ERROR";
840+
log.warn("Elasticsearch returned non-200 response code: " + restCallResult.getResponseCode());
841+
return "{\"hits\": {\"hits\": []}, \"error\": \"Elasticsearch request failed with code " + restCallResult.getResponseCode() + "\"}";
841842
}
842843
return restCallResult.getResponse();
843844
} catch (Exception e) {
844845
log.error("Problem performing REST call to get log data (URL=" + urlString + ")", e);
846+
return "{\"hits\": {\"hits\": []}, \"error\": \"Exception: " + e.getMessage() + "\"}";
845847
}
846-
847-
return "ERROR";
848848
}
849849

850850

0 commit comments

Comments
 (0)