From 2064e56f72c75eac68773bf35de81c081cb04231 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 23 Jun 2017 12:09:16 +0200 Subject: More specific exceptions in JvppReplyConsumer Change-Id: I96bd342e84742f6c6ab7d4c6aa687bcb1baf9e7c Signed-off-by: Marek Gradzki --- .../common/translate/util/JvppReplyConsumer.java | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java index 2a8345445..9fe9162c5 100644 --- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java +++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java @@ -16,26 +16,24 @@ package io.fd.hc2vpp.common.translate.util; +import static com.google.common.base.Preconditions.checkArgument; + import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.dto.JVppReply; import java.util.Optional; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkState; - /** * Trait providing logic for consuming reply's to jvpp api calls */ @@ -81,7 +79,7 @@ public interface JvppReplyConsumer { default > REP getReplyForCreate(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnull final DataObject data) - throws WriteFailedException { + throws WriteFailedException.CreateFailedException { return getReplyForCreate(future, replyType, data, JvppReplyTimeoutHolder.getTimeout()); } @@ -92,13 +90,14 @@ public interface JvppReplyConsumer { @Nonnull final InstanceIdentifier replyType, @Nonnull final DataObject data, @Nonnegative final int timeoutInSeconds) - throws WriteFailedException { + throws WriteFailedException.CreateFailedException { try { return getReply(future, timeoutInSeconds); } catch (VppBaseCallException e) { throw new WriteFailedException.CreateFailedException(replyType, data, e); } catch (TimeoutException e) { - throw new WriteTimeoutException(replyType, e); + throw new WriteFailedException.CreateFailedException(replyType, data, + new WriteTimeoutException(replyType, e)); } } @@ -109,7 +108,7 @@ public interface JvppReplyConsumer { @Nonnull final InstanceIdentifier replyType, @Nonnull final DataObject dataBefore, @Nonnull final DataObject dataAfter) - throws WriteFailedException { + throws WriteFailedException.UpdateFailedException { return getReplyForUpdate(future, replyType, dataBefore, dataAfter, JvppReplyTimeoutHolder.getTimeout()); } @@ -121,13 +120,14 @@ public interface JvppReplyConsumer { @Nonnull final DataObject dataBefore, @Nonnull final DataObject dataAfter, @Nonnegative final int timeoutInSeconds) - throws WriteFailedException { + throws WriteFailedException.UpdateFailedException { try { return getReply(future, timeoutInSeconds); } catch (VppBaseCallException e) { throw new WriteFailedException.UpdateFailedException(replyType, dataBefore, dataAfter, e); } catch (TimeoutException e) { - throw new WriteTimeoutException(replyType, e); + throw new WriteFailedException.UpdateFailedException(replyType, dataBefore, dataAfter, + new WriteTimeoutException(replyType, e)); } } @@ -136,7 +136,7 @@ public interface JvppReplyConsumer { */ default > REP getReplyForDelete(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType) - throws WriteFailedException { + throws WriteFailedException.DeleteFailedException { return getReplyForDelete(future, replyType, JvppReplyTimeoutHolder.getTimeout()); } @@ -146,13 +146,13 @@ public interface JvppReplyConsumer { default > REP getReplyForDelete(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnegative final int timeoutInSeconds) - throws WriteFailedException { + throws WriteFailedException.DeleteFailedException { try { return getReply(future, timeoutInSeconds); } catch (VppBaseCallException e) { throw new WriteFailedException.DeleteFailedException(replyType, e); } catch (TimeoutException e) { - throw new WriteTimeoutException(replyType, e); + throw new WriteFailedException.DeleteFailedException(replyType, new WriteTimeoutException(replyType, e)); } } -- cgit 1.2.3-korg