Skip to content

Commit

Permalink
Fix a fetcher test for the ShortDOIService (#6945)
Browse files Browse the repository at this point in the history
* throw an exception if no result was returned

* fix formatting issue
  • Loading branch information
Toromtomtom authored Sep 26, 2020
1 parent a0ca875 commit d767d72
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ private JSONObject makeRequest(DOI doi) throws ShortDOIServiceException {
URLDownload urlDownload = new URLDownload(url);

try {
return JsonReader.toJsonObject(urlDownload.asInputStream());
JSONObject resultAsJSON = JsonReader.toJsonObject(urlDownload.asInputStream());
if (resultAsJSON.isEmpty()) {
throw new ShortDOIServiceException("Cannot get short DOI");
}
return resultAsJSON;
} catch (ParseException | IOException | JSONException e) {
throw new ShortDOIServiceException("Cannot get short DOI", e);
}
Expand Down

0 comments on commit d767d72

Please sign in to comment.