From 42329b124753c7cf3d32a6b8a30515e7e349180d Mon Sep 17 00:00:00 2001 From: Tomas Cere Date: Mon, 21 Dec 2015 13:51:37 +0100 Subject: [PATCH] BUG 3015 - restconf: 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 port of : https://git.opendaylight.org/gerrit/#/c/23277/2 Change-Id: I12a457bf948bf13040c41e393284e0748b1bcaed Signed-off-by: Tomas Cere --- .../opendaylight/netconf/sal/restconf/impl/RestconfImpl.java | 3 +++ .../controller/sal/restconf/impl/test/InvokeRpcMethodTest.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java b/opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java index 18b02cfa34..bc2d23cd70 100644 --- a/opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java +++ b/opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/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; @@ -488,6 +489,8 @@ 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); } else { diff --git a/opendaylight/restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java b/opendaylight/restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java index 9db5f45b3e..02264c366b 100644 --- a/opendaylight/restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java +++ b/opendaylight/restconf/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