use of org.apache.cxf.microprofile.client.MicroProfileClientProviderFactory in project cxf by apache.
the class MicroProfileClientProxyImpl method checkResponse.
@Override
protected void checkResponse(Method m, Response r, Message inMessage) throws Throwable {
MicroProfileClientProviderFactory factory = MicroProfileClientProviderFactory.getInstance(inMessage);
List<ResponseExceptionMapper<?>> mappers = factory.createResponseExceptionMapper(inMessage, Throwable.class);
for (ResponseExceptionMapper<?> mapper : mappers) {
if (mapper.handles(r.getStatus(), r.getHeaders())) {
Throwable t = mapper.toThrowable(r);
if (t == null) {
continue;
}
if (t instanceof RuntimeException) {
throw t;
} else if (CompletionStage.class.isAssignableFrom(m.getReturnType())) {
throw new CompletionException(t);
} else if (m.getExceptionTypes() != null) {
// its a checked exception, make sure its declared
for (Class<?> c : m.getExceptionTypes()) {
if (c.isAssignableFrom(t.getClass())) {
throw t;
}
}
if (LOG.isLoggable(Level.FINEST)) {
LOG.log(Level.FINEST, "ResponseExceptionMapper, " + mapper.getClass().getName() + ", handles " + "response, but client method does not declare it's Throwable type, " + t.getClass().getName());
}
}
}
}
}
Aggregations