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…
Reference in New Issue