use of org.eclipse.hono.client.MessageUndeliverableException in project hono by eclipse.
the class GenericSenderLink method mapUnacceptedOutcomeToErrorResult.
private Future<ProtonDelivery> mapUnacceptedOutcomeToErrorResult(final ProtonDelivery delivery) {
final DeliveryState remoteState = delivery.getRemoteState();
if (Accepted.class.isInstance(remoteState)) {
throw new IllegalStateException("delivery is expected to be rejected, released or modified here, not accepted");
}
ServiceInvocationException e = null;
if (Rejected.class.isInstance(remoteState)) {
final Rejected rejected = (Rejected) remoteState;
e = Optional.ofNullable(rejected.getError()).map(StatusCodeMapper::fromTransferError).orElseGet(() -> new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST));
} else if (Released.class.isInstance(remoteState)) {
e = new MessageNotProcessedException();
} else if (Modified.class.isInstance(remoteState)) {
final Modified modified = (Modified) remoteState;
if (modified.getUndeliverableHere()) {
e = new MessageUndeliverableException();
} else {
e = new MessageNotProcessedException();
}
}
return Future.failedFuture(e);
}
Aggregations