Decouple config and netconf subsystems.
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / netconf / impl / util / DeserializerExceptionHandler.java
index b27cd2017292cd3995ff50db08ba952a44c4a03c..15205e4bed75e3440420c404dc90d3ead0ed5400 100644 (file)
@@ -8,19 +8,19 @@
 
 package org.opendaylight.controller.netconf.impl.util;
 
-import java.util.Map;
-
-import org.opendaylight.controller.netconf.api.NetconfDeserializerException;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.util.messages.SendErrorExceptionUtil;
-
 import com.google.common.collect.Maps;
-
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
+import java.util.Map;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.netconf.util.messages.SendErrorExceptionUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class DeserializerExceptionHandler implements ChannelHandler {
 
+    private static final Logger LOG = LoggerFactory.getLogger(DeserializerExceptionHandler.class);
+
     @Override
     public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
         // NOOP
@@ -33,18 +33,17 @@ public final class DeserializerExceptionHandler implements ChannelHandler {
 
     @Override
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
-        if (cause instanceof NetconfDeserializerException) {
-            handleDeserializerException(ctx, cause);
-        }
+        LOG.warn("An exception occurred during message handling", cause);
+        handleDeserializerException(ctx, cause);
     }
 
     private void handleDeserializerException(ChannelHandlerContext ctx, Throwable cause) {
 
         Map<String, String> info = Maps.newHashMap();
         info.put("cause", cause.getMessage());
-        NetconfDocumentedException ex = new NetconfDocumentedException(cause.getMessage(),
-                NetconfDocumentedException.ErrorType.rpc, NetconfDocumentedException.ErrorTag.malformed_message,
-                NetconfDocumentedException.ErrorSeverity.error, info);
+        DocumentedException ex = new DocumentedException(cause.getMessage(),
+                DocumentedException.ErrorType.rpc, DocumentedException.ErrorTag.malformed_message,
+                DocumentedException.ErrorSeverity.error, info);
 
         SendErrorExceptionUtil.sendErrorMessage(ctx.channel(), ex);
     }