From: Tomas Cere Date: Mon, 21 Dec 2015 12:51:37 +0000 (+0100) Subject: BUG 3015 - restconf: Un-helpful error message presented when no service X-Git-Tag: release/beryllium~41^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=42329b124753c7cf3d32a6b8a30515e7e349180d;p=netconf.git 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 --- 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()); } }