Log errors, don't throw them down a hole
This commit is contained in:
parent
36f4524c7e
commit
093904abb1
|
@ -40,6 +40,9 @@ import org.hl7.fhir.r5.utils.client.network.Client;
|
||||||
import org.hl7.fhir.r5.utils.client.network.ResourceRequest;
|
import org.hl7.fhir.r5.utils.client.network.ResourceRequest;
|
||||||
import org.hl7.fhir.utilities.ToolingClientLogger;
|
import org.hl7.fhir.utilities.ToolingClientLogger;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -75,6 +78,9 @@ import java.util.stream.Stream;
|
||||||
*/
|
*/
|
||||||
public class FHIRToolingClient {
|
public class FHIRToolingClient {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FHIRToolingClient.class);
|
||||||
|
|
||||||
|
|
||||||
public static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssK";
|
public static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssK";
|
||||||
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||||
public static final String hostKey = "http.proxyHost";
|
public static final String hostKey = "http.proxyHost";
|
||||||
|
@ -144,7 +150,6 @@ public class FHIRToolingClient {
|
||||||
private <T extends Resource> T getCapabilities(URI resourceUri, String message, String exceptionMessage) throws FHIRException {
|
private <T extends Resource> T getCapabilities(URI resourceUri, String message, String exceptionMessage) throws FHIRException {
|
||||||
final List<ResourceFormat> resourceFormats = getResourceFormatsWithPreferredFirst();
|
final List<ResourceFormat> resourceFormats = getResourceFormatsWithPreferredFirst();
|
||||||
|
|
||||||
FHIRException fhirException = null;
|
|
||||||
for (ResourceFormat attemptedResourceFormat : resourceFormats) {
|
for (ResourceFormat attemptedResourceFormat : resourceFormats) {
|
||||||
try {
|
try {
|
||||||
T output = (T) client.issueGetResourceRequest(resourceUri,
|
T output = (T) client.issueGetResourceRequest(resourceUri,
|
||||||
|
@ -157,12 +162,10 @@ public class FHIRToolingClient {
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fhirException = fhirException == null
|
logger.warn("Failed attempt to fetch " + resourceUri, e);
|
||||||
? new FHIRException(exceptionMessage)
|
|
||||||
: new FHIRException(exceptionMessage, fhirException);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw fhirException;
|
throw new FHIRException(exceptionMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminologyCapabilities getTerminologyCapabilities() {
|
public TerminologyCapabilities getTerminologyCapabilities() {
|
||||||
|
|
|
@ -212,7 +212,6 @@ class FHIRToolingClientTest {
|
||||||
assertEquals(ResourceFormat.RESOURCE_JSON.getHeader(), toolingClient.getPreferredResourceFormat());
|
assertEquals(ResourceFormat.RESOURCE_JSON.getHeader(), toolingClient.getPreferredResourceFormat());
|
||||||
toolingClient.setClientHeaders(getHeaders());
|
toolingClient.setClientHeaders(getHeaders());
|
||||||
Exception exception = assertThrows(FHIRException.class, () -> { ArgumentCaptor<Headers> headersArgumentCaptor = ArgumentCaptor.forClass(Headers.class);
|
Exception exception = assertThrows(FHIRException.class, () -> { ArgumentCaptor<Headers> headersArgumentCaptor = ArgumentCaptor.forClass(Headers.class);
|
||||||
|
|
||||||
toolingClient.getCapabilitiesStatement(); });
|
toolingClient.getCapabilitiesStatement(); });
|
||||||
assertEquals(ResourceFormat.RESOURCE_JSON.getHeader(), toolingClient.getPreferredResourceFormat());
|
assertEquals(ResourceFormat.RESOURCE_JSON.getHeader(), toolingClient.getPreferredResourceFormat());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue