From 6c307c16a48781dfc1623b75afb31635760f8395 Mon Sep 17 00:00:00 2001 From: Jan Hajnar Date: Thu, 25 Jun 2015 16:43:26 +0200 Subject: [PATCH] Bug 3015 - netconf: Un-helpful error message presented when no service provider is there to handle the RPC call. * added catch in checkRpcResponse when cause of error is unimplemented rpc service Change-Id: I5b19827c63cd4b7962f55da79d4887bbff6b68ca Signed-off-by: Jan Hajnar --- .../controller/sal/restconf/impl/RestconfImpl.java | 4 ++++ .../sal/restconf/impl/test/InvokeRpcMethodTest.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java index 98b75e7f06..6bdc98c36e 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java @@ -47,6 +47,7 @@ import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedEx import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; @@ -482,6 +483,9 @@ public class RestconfImpl implements RestconfService { if (cause instanceof IllegalArgumentException) { throw new RestconfDocumentedException(cause.getMessage(), ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); + } else if (cause instanceof DOMRpcImplementationNotAvailableException) { + throw new RestconfDocumentedException(cause.getMessage(), ErrorType.APPLICATION, + ErrorTag.OPERATION_NOT_SUPPORTED); } throw new RestconfDocumentedException("The operation encountered an unexpected error while executing.",cause); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java index 8ed2f48ee1..96adc94df6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java @@ -178,7 +178,7 @@ public class InvokeRpcMethodTest { restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo); fail("Expected an exception to be thrown."); } catch (final RestconfDocumentedException e) { - verifyRestconfDocumentedException(e, 0, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, + verifyRestconfDocumentedException(e, 0, ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED, Optional. absent(), Optional. absent()); } } -- 2.36.6