mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-07 21:38:15 +00:00
Catch ClassCastException and report clearer error message
This commit is contained in:
parent
003be69129
commit
8a3d7d3670
@ -171,10 +171,13 @@ public class FHIRToolingClient {
|
||||
public TerminologyCapabilities getTerminologyCapabilities() {
|
||||
TerminologyCapabilities capabilities = null;
|
||||
|
||||
capabilities = getCapabilities(resourceAddress.resolveMetadataTxCaps(),
|
||||
try {
|
||||
capabilities = getCapabilities(resourceAddress.resolveMetadataTxCaps(),
|
||||
"TerminologyCapabilities",
|
||||
"Error fetching the server's terminology capabilities");
|
||||
|
||||
} catch (ClassCastException e) {
|
||||
throw new FHIRException("Unexpected response format for Terminology Capability metadata", e);
|
||||
}
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,7 @@ import okhttp3.Headers;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.internal.http2.Header;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
class FHIRToolingClientTest {
|
||||
@ -171,10 +170,9 @@ class FHIRToolingClientTest {
|
||||
ArgumentCaptor<Headers> headersArgumentCaptor = ArgumentCaptor.forClass(Headers.class);
|
||||
toolingClient.setClientHeaders(getHeaders());
|
||||
Exception exception = assertThrows(FHIRException.class, () -> {
|
||||
|
||||
toolingClient.getTerminologyCapabilities();
|
||||
|
||||
});
|
||||
assertEquals(exception.getCause().getClass(), ClassCastException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user