Bug 3015 - netconf: Un-helpful error message presented when no service 77/23277/3
authorJan Hajnar <jhajnar@cisco.com>
Thu, 25 Jun 2015 14:43:26 +0000 (16:43 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 25 Jan 2016 16:49:27 +0000 (16:49 +0000)
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 <jhajnar@cisco.com>
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java

index 98b75e7f06c3c9196c4f3b4e1594e42875ebecc0..6bdc98c36e96f5df97004337a650a4e80a3b56bb 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;
@@ -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);
             }
index 8ed2f48ee122c5e9aff633d0e601b3b399ef1d2a..96adc94df6079fceba1eb971698d26326a1cc43b 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());
         }
     }