BUG 3015 - restconf: Un-helpful error message presented when no service 95/31695/1
authorTomas Cere <tcere@cisco.com>
Mon, 21 Dec 2015 12:51:37 +0000 (13:51 +0100)
committerTomas Cere <tcere@cisco.com>
Mon, 21 Dec 2015 13:09:03 +0000 (14:09 +0100)
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 <tcere@cisco.com>
opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java
opendaylight/restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java

index 18b02cfa3449f32954f54320852aa500bf20947d..bc2d23cd70f052cde95e2a304b40f1786a626b70 100644 (file)
@@ -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 {
index 9db5f45b3e607dd872d87d869757943551f4579e..02264c366b3a433c58f0933bad69911bf880b867 100644 (file)
@@ -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.<String> absent(), Optional.<String> absent());
         }
     }