Source:
<code>public Optional<ExternalDataObject> getExternalDataObject(String id) { HttpGet method = null; SHERPAResponse sherpaResponse = null; int timeout = 5000; URIBuilder uriBuilder = null; try { uriBuilder = new URIBuilder(url); uriBuilder.addParameter("jtitle", id); if (StringUtils.isNotBlank(apiKey)) { uriBuilder.addParameter("ak", apiKey); } method = new HttpGet(uriBuilder.build()); method.setConfig(RequestConfig.custom() .setConnectionRequestTimeout(timeout) .setConnectTimeout(timeout) .setSocketTimeout(timeout) .build()); HttpResponse response = client.execute(method); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { sherpaResponse = new SHERPAResponse("SHERPA/RoMEO return not OK status: " + statusCode); } HttpEntity responseBody = response.getEntity(); if (null != responseBody) { sherpaResponse = new SHERPAResponse(responseBody.getContent()); } else { sherpaResponse = new SHERPAResponse("SHERPA/RoMEO returned no response"); } } catch (Exception e) { <START> log.error(e.getMessage(), e); <END> } if (sherpaResponse == null) { sherpaResponse = new SHERPAResponse( "Error processing the SHERPA/RoMEO answer"); } if (CollectionUtils.isNotEmpty(sherpaResponse.getJournals())) { SHERPAJournal sherpaJournal = sherpaResponse.getJournals().get(0); ExternalDataObject externalDataObject = constructExternalDataObjectFromSherpaJournal(sherpaJournal); return Optional.of(externalDataObject); } return null; }</code><technical_language>Again, prefer a more descriptive error message here. : log.error("Error searching SHERPA API for Journal data", e); UPDATE: in this file log.error("SHERPA/RoMEO query failed: ", e); "good enough" for me. a custom message in log.error statements</technical_language>

Target:
public Optional<ExternalDataObject> getExternalDataObject(String id) { HttpGet method = null; SHERPAResponse sherpaResponse = null; int timeout = 5000; URIBuilder uriBuilder = null; try { uriBuilder = new URIBuilder(url); uriBuilder.addParameter("jtitle", id); if (StringUtils.isNotBlank(apiKey)) { uriBuilder.addParameter("ak", apiKey); } method = new HttpGet(uriBuilder.build()); method.setConfig(RequestConfig.custom() .setConnectionRequestTimeout(timeout) .setConnectTimeout(timeout) .setSocketTimeout(timeout) .build()); HttpResponse response = client.execute(method); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { sherpaResponse = new SHERPAResponse("SHERPA/RoMEO return not OK status: " + statusCode); } HttpEntity responseBody = response.getEntity(); if (null != responseBody) { sherpaResponse = new SHERPAResponse(responseBody.getContent()); } else { sherpaResponse = new SHERPAResponse("SHERPA/RoMEO returned no response"); } } catch (Exception e) { log.error("SHERPA/RoMEO query failed: ", e); } if (sherpaResponse == null) { sherpaResponse = new SHERPAResponse( "Error processing the SHERPA/RoMEO answer"); } if (CollectionUtils.isNotEmpty(sherpaResponse.getJournals())) { SHERPAJournal sherpaJournal = sherpaResponse.getJournals().get(0); ExternalDataObject externalDataObject = constructExternalDataObjectFromSherpaJournal(sherpaJournal); return Optional.of(externalDataObject); } return null; }