Bug 451 - Fix netconf exception handling
[controller.git] / opendaylight / netconf / netconf-util / src / main / java / org / opendaylight / controller / netconf / util / mapping / AbstractLastNetconfOperation.java
index d6d57c50aceabf543bcc367bb8022ccc79b1ec72..c40bf3909a029e275467ce7c987fa6fe05063e2c 100644 (file)
@@ -14,8 +14,6 @@ import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import com.google.common.base.Preconditions;
-
 public abstract class AbstractLastNetconfOperation extends AbstractNetconfOperation {
 
     protected AbstractLastNetconfOperation(String netconfSessionIdForReporting) {
@@ -25,8 +23,12 @@ public abstract class AbstractLastNetconfOperation extends AbstractNetconfOperat
     @Override
     protected Element handle(Document document, XmlElement operationElement,
             NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
-        Preconditions.checkArgument(subsequentOperation.isExecutionTermination(),
-                "No netconf operation expected to be subsequent to %s, but is %s", this, subsequentOperation);
+        if (!subsequentOperation.isExecutionTermination()){
+            throw new NetconfDocumentedException(String.format("No netconf operation expected to be subsequent to %s, but is %s", this, subsequentOperation),
+                    NetconfDocumentedException.ErrorType.application,
+                    NetconfDocumentedException.ErrorTag.malformed_message,
+                    NetconfDocumentedException.ErrorSeverity.error);
+        }
 
         return handleWithNoSubsequentOperations(document, operationElement);
     }