Remove DocumentedException.ErrorSeverity
[netconf.git] / netconf / netconf-impl / src / main / java / org / opendaylight / netconf / impl / util / DeserializerExceptionHandler.java
index ca270022a97cc631372064901fea1cfbfa78cec2..f137dd1f5b3539525b2c04c177c4ab28f8ab8726 100644 (file)
@@ -5,15 +5,15 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.impl.util;
 
-import com.google.common.collect.Maps;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
+import java.util.HashMap;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.util.messages.SendErrorExceptionUtil;
+import org.opendaylight.yangtools.yang.common.ErrorSeverity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -22,28 +22,27 @@ public final class DeserializerExceptionHandler implements ChannelHandler {
     private static final Logger LOG = LoggerFactory.getLogger(DeserializerExceptionHandler.class);
 
     @Override
-    public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
+    public void handlerAdded(final ChannelHandlerContext ctx) {
         // NOOP
     }
 
     @Override
-    public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
+    public void handlerRemoved(final ChannelHandlerContext ctx) {
         // NOOP
     }
 
     @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+    public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable 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();
+    private static void handleDeserializerException(final ChannelHandlerContext ctx, final Throwable cause) {
+        final Map<String, String> info = new HashMap<>();
         info.put("cause", cause.getMessage());
-        DocumentedException ex = new DocumentedException(cause.getMessage(),
-                DocumentedException.ErrorType.rpc, DocumentedException.ErrorTag.malformed_message,
-                DocumentedException.ErrorSeverity.error, info);
+        final DocumentedException ex = new DocumentedException(cause.getMessage(),
+                DocumentedException.ErrorType.RPC, DocumentedException.ErrorTag.MALFORMED_MESSAGE,
+                ErrorSeverity.ERROR, info);
 
         SendErrorExceptionUtil.sendErrorMessage(ctx.channel(), ex);
     }