fixes to catch proper netconf exception

- part of ONOS-7020

Change-Id: I55c02ca9fdb97f1ae12b4e3d7b76da565f9da741
diff --git a/drivers/cisco/netconf/src/main/java/org/onosproject/drivers/cisco/CiscoIosDeviceDescription.java b/drivers/cisco/netconf/src/main/java/org/onosproject/drivers/cisco/CiscoIosDeviceDescription.java
index b1b315a..8839c59 100644
--- a/drivers/cisco/netconf/src/main/java/org/onosproject/drivers/cisco/CiscoIosDeviceDescription.java
+++ b/drivers/cisco/netconf/src/main/java/org/onosproject/drivers/cisco/CiscoIosDeviceDescription.java
@@ -30,7 +30,6 @@
 import org.onosproject.netconf.NetconfException;
 import org.onosproject.netconf.NetconfSession;
 import org.slf4j.Logger;
-import java.io.IOException;
 import java.util.List;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.slf4j.LoggerFactory.getLogger;
@@ -49,7 +48,7 @@
         NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
         try {
             version = session.get(showVersionRequestBuilder());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new RuntimeException(new NetconfException("Failed to retrieve version info.", e));
         }
 
@@ -71,7 +70,7 @@
         NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
         try {
             interfaces = session.get(showInterfacesRequestBuilder());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Failed to retrieve Interfaces");
             return ImmutableList.of();
         }
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuT100DeviceDescription.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuT100DeviceDescription.java
index 32dd5cd..142b53a 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuT100DeviceDescription.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuT100DeviceDescription.java
@@ -33,11 +33,11 @@
 import org.onosproject.net.device.PortDescription;
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.onosproject.netconf.NetconfSession;
 import org.slf4j.Logger;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -68,7 +68,7 @@
         String reply;
         try {
             reply = session.get(requestBuilder());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Failed to retrieve port details for device {}", handler().data().deviceId());
             return ImmutableList.of();
         }
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlarmConsumer.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlarmConsumer.java
index f0ae5fe..01df800 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlarmConsumer.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlarmConsumer.java
@@ -27,11 +27,11 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.onosproject.mastership.MastershipService;
 
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.text.SimpleDateFormat;
@@ -138,7 +138,7 @@
                 alarms = parseVoltActiveAlerts(XmlConfigParser.
                     loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8))));
             }
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Error reading alarms for device {} exception {}", ncDeviceId, e);
         }
 
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfig.java
index 860d6e1..18fe8ee 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfig.java
@@ -21,10 +21,10 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.onosproject.mastership.MastershipService;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.Set;
 
 import com.google.common.collect.ImmutableSet;
@@ -79,7 +79,7 @@
                     .get(ncDeviceId)
                     .getSession()
                     .get(request.toString(), REPORT_ALL);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
@@ -118,7 +118,7 @@
 
             controller.getDevicesMap().get(ncDeviceId).getSession().
                     editConfig(RUNNING, null, request.toString());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
             return false;
         }
@@ -159,7 +159,7 @@
                 controller.getDevicesMap().get(ncDeviceId).getSession().
                         startSubscription(request.toString());
             }
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
             return false;
         }
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltControllerConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltControllerConfig.java
index 2431d2d..9d5ba5c 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltControllerConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltControllerConfig.java
@@ -37,7 +37,6 @@
 import org.slf4j.Logger;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
@@ -110,7 +109,7 @@
                 log.debug("Reply XML {}", reply);
                 controllers.addAll(parseStreamVoltControllers(XmlConfigParser.
                         loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8)))));
-            } catch (IOException e) {
+            } catch (NetconfException e) {
                 log.error("Cannot communicate to device {} ", ncDeviceId);
             }
         } else {
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltFwdlConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltFwdlConfig.java
index f48024e..05c4466 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltFwdlConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltFwdlConfig.java
@@ -22,10 +22,9 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
-import java.io.IOException;
-
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtility.*;
 import static org.slf4j.LoggerFactory.getLogger;
@@ -136,7 +135,7 @@
                     .get(ncDeviceId)
                     .getSession()
                     .doWrappedRpc(request.toString());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNeConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNeConfig.java
index 59b6bf2..90b2678 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNeConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNeConfig.java
@@ -22,10 +22,9 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
-import java.io.IOException;
-
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtility.*;
 import static org.slf4j.LoggerFactory.getLogger;
@@ -67,7 +66,7 @@
                     .get(ncDeviceId)
                     .getSession()
                     .get(request.toString(), REPORT_ALL);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfig.java
index c304609..2ae393c 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfig.java
@@ -22,9 +22,9 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.Set;
 
 import com.google.common.collect.ImmutableSet;
@@ -99,7 +99,7 @@
                         .get(ncDeviceId)
                         .getSession()
                         .get(request.toString(), REPORT_ALL);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
@@ -166,7 +166,7 @@
                 .get(ncDeviceId)
                 .getSession()
                 .editConfig(RUNNING, null, request.toString());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
             return false;
         }
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuConfig.java
index 56113cb..9174464 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuConfig.java
@@ -23,9 +23,9 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -118,7 +118,7 @@
                         .get(ncDeviceId)
                         .getSession()
                         .get(request.toString(), REPORT_ALL);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
@@ -180,7 +180,7 @@
                         .get(ncDeviceId)
                         .getSession()
                         .doWrappedRpc(request.toString());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
@@ -255,7 +255,7 @@
                         .get(ncDeviceId)
                         .getSession()
                         .get(request.toString(), REPORT_ALL);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfig.java
index 1af5e34..a126694 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfig.java
@@ -23,9 +23,9 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -88,7 +88,7 @@
                     .get(ncDeviceId)
                     .getSession()
                     .doWrappedRpc(request.toString());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
@@ -157,7 +157,7 @@
                     .get(ncDeviceId)
                     .getSession()
                     .doWrappedRpc(request.toString());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java
index bbf405c..675378b 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java
@@ -22,9 +22,9 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 import java.util.HashMap;
@@ -138,7 +138,7 @@
                         .get(ncDeviceId)
                         .getSession()
                         .get(request.toString(), REPORT_ALL);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return reply;
@@ -186,7 +186,7 @@
 
             result = controller.getDevicesMap().get(ncDeviceId).getSession().
                     editConfig(RUNNING, null, request.toString());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
         }
         return result;
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDeviceDescription.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDeviceDescription.java
index 1693a09..5162b48 100644
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDeviceDescription.java
+++ b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDeviceDescription.java
@@ -33,7 +33,6 @@
 import org.onosproject.netconf.NetconfSession;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 
@@ -79,7 +78,7 @@
         String sysInfo;
         try {
             sysInfo = session.get(getVersionReq());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new IllegalArgumentException(
                     new NetconfException(DEV_INFO_FAILURE));
         }
@@ -191,7 +190,7 @@
         String interfaces = null;
         try {
             interfaces = session.get(getInterfacesReq());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.info("Failed to retrive interface {} ", e.getMessage());
         }
         return interfaces;
diff --git a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/DeviceDiscoveryJuniperImpl.java b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/DeviceDiscoveryJuniperImpl.java
index f61b837..c60c448 100644
--- a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/DeviceDiscoveryJuniperImpl.java
+++ b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/DeviceDiscoveryJuniperImpl.java
@@ -25,10 +25,10 @@
 import org.onosproject.net.device.PortDescription;
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.onosproject.netconf.NetconfSession;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.List;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -59,7 +59,7 @@
         try {
             sysInfo = session.get(requestBuilder(REQ_SYS_INFO));
             chassis = session.get(requestBuilder(REQ_MAC_ADD_INFO));
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.warn("Failed to retrieve device details for {}", devId);
             return null;
         }
@@ -80,7 +80,7 @@
         String reply;
         try {
             reply = session.get(requestBuilder(REQ_IF_INFO));
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.warn("Failed to retrieve ports for device {}", devId);
             return ImmutableList.of();
         }
diff --git a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/FlowRuleJuniperImpl.java b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/FlowRuleJuniperImpl.java
index 18d08dd..d4c09dc 100644
--- a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/FlowRuleJuniperImpl.java
+++ b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/FlowRuleJuniperImpl.java
@@ -42,7 +42,6 @@
 import org.onosproject.netconf.NetconfException;
 import org.onosproject.netconf.NetconfSession;
 
-import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
@@ -100,7 +99,7 @@
         String reply;
         try {
             reply = session.get(routingTableBuilder());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new RuntimeException(new NetconfException("Failed to retrieve configuration.",
                     e));
         }
@@ -241,7 +240,7 @@
                             type == ADD ? "added" : "removed", staticRoute);
                 }
             }
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new RuntimeException(new NetconfException("Failed to retrieve configuration.",
                     e));
         }
@@ -335,7 +334,7 @@
         String replay;
         try {
             replay = session.get(commitBuilder());
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new RuntimeException(new NetconfException("Failed to retrieve configuration.",
                     e));
         }
@@ -355,7 +354,7 @@
         String replay;
         try {
             replay = session.get(rollbackBuilder(0));
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new RuntimeException(new NetconfException("Failed to retrieve configuration.",
                     e));
         }
diff --git a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/LinkDiscoveryJuniperImpl.java b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/LinkDiscoveryJuniperImpl.java
index fb15c3e..613f6d4 100644
--- a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/LinkDiscoveryJuniperImpl.java
+++ b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/LinkDiscoveryJuniperImpl.java
@@ -27,10 +27,10 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.net.link.LinkDescription;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.onosproject.netconf.NetconfSession;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.util.HashSet;
 import java.util.Optional;
 import java.util.Set;
@@ -66,7 +66,7 @@
         String reply;
         try {
             reply = session.get(requestBuilder(REQ_LLDP_NBR_INFO));
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.warn("Failed to retrieve ports for device {}", localDeviceId);
             return ImmutableSet.of();
         }
diff --git a/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/NetconfConfigGetter.java b/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/NetconfConfigGetter.java
index 087af0c..039b760 100644
--- a/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/NetconfConfigGetter.java
+++ b/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/NetconfConfigGetter.java
@@ -19,8 +19,6 @@
 import static org.onosproject.netconf.DatastoreId.datastore;
 import static org.slf4j.LoggerFactory.getLogger;
 
-import java.io.IOException;
-
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.onosproject.net.DeviceId;
@@ -30,6 +28,7 @@
 import org.onosproject.net.packet.PacketProcessor;
 import org.onosproject.net.packet.PacketService;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
 import com.google.common.base.Preconditions;
@@ -69,7 +68,7 @@
         try {
             return controller.getDevicesMap().get(ofDeviceId).getSession()
                     .getConfig(datastore(type.replace("cfgType=", "")));
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Configuration could not be retrieved {}", e.getMessage());
         }
         return UNABLE_TO_READ_CONFIG;
diff --git a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigGetter.java b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigGetter.java
index 2739872..a353c28 100644
--- a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigGetter.java
+++ b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigGetter.java
@@ -23,10 +23,9 @@
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.DatastoreId;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
-import java.io.IOException;
-
 import static org.slf4j.LoggerFactory.getLogger;
 
 /**
@@ -57,7 +56,7 @@
                     get(ofDeviceId).
                     getSession().
                     getConfig(DatastoreId.datastore(type));
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Configuration could not be retrieved {}",
                       e.getMessage());
         }
diff --git a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigSetter.java b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigSetter.java
index 138aa4f..6102b1a 100644
--- a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigSetter.java
+++ b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigSetter.java
@@ -22,6 +22,7 @@
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
 import java.io.IOException;
@@ -68,7 +69,7 @@
                     .get(deviceId)
                     .getSession()
                     .requestSync(request);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Configuration could not be set", e);
         }
         return UNABLE_TO_SET_CONFIG;
diff --git a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfControllerConfig.java b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfControllerConfig.java
index 6a8710d..70f01a6 100644
--- a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfControllerConfig.java
+++ b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfControllerConfig.java
@@ -27,11 +27,10 @@
 import org.onosproject.netconf.DatastoreId;
 import org.onosproject.netconf.NetconfController;
 import org.onosproject.netconf.NetconfDevice;
-
+import org.onosproject.netconf.NetconfException;
 import org.slf4j.Logger;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
@@ -63,7 +62,7 @@
                 log.debug("Reply XML {}", reply);
                 controllers.addAll(XmlConfigParser.parseStreamControllers(XmlConfigParser.
                         loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8)))));
-            } catch (IOException e) {
+            } catch (NetconfException e) {
                 log.error("Cannot communicate with device {} ", deviceId, e);
             }
         } else {
@@ -95,14 +94,14 @@
                                     new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8))),
                             "running", "merge", "create", controllers
                     );
-                } catch (IOException e) {
+                } catch (NetconfException e) {
                     log.error("Cannot comunicate to device {} , exception {}", deviceId, e.getMessage());
                 }
                 device.getSession().editConfig(config.substring(config.indexOf("-->") + 3));
             } catch (NullPointerException e) {
                 log.warn("No NETCONF device with requested parameters " + e);
                 throw new NullPointerException("No NETCONF device with requested parameters " + e);
-            } catch (IOException e) {
+            } catch (NetconfException e) {
                 log.error("Cannot comunicate to device {} , exception {}", deviceId, e.getMessage());
             }
         } else {
diff --git a/drivers/oplink/src/main/java/org/onosproject/drivers/oplink/OplinkNetconfUtility.java b/drivers/oplink/src/main/java/org/onosproject/drivers/oplink/OplinkNetconfUtility.java
index 2f59b0f..c7053da 100644
--- a/drivers/oplink/src/main/java/org/onosproject/drivers/oplink/OplinkNetconfUtility.java
+++ b/drivers/oplink/src/main/java/org/onosproject/drivers/oplink/OplinkNetconfUtility.java
@@ -25,7 +25,6 @@
 import org.onosproject.netconf.NetconfException;
 import org.onosproject.netconf.NetconfSession;
 
-import java.io.IOException;
 import java.util.List;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -68,7 +67,7 @@
         String reply;
         try {
             reply = session.get(filter, null);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new RuntimeException(new NetconfException("Failed to retrieve configuration.", e));
         }
         return reply;
@@ -87,7 +86,7 @@
         String reply;
         try {
             reply = session.getConfig(DatastoreId.RUNNING, filter);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new RuntimeException(new NetconfException("Failed to retrieve configuration.", e));
         }
         return reply;
@@ -107,7 +106,7 @@
         boolean reply = false;
         try {
             reply = session.editConfig(DatastoreId.RUNNING, mode, cfg);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             throw new RuntimeException(new NetconfException("Failed to edit configuration.", e));
         }
         return reply;
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/cli/impl/NetconfConfigGetCommand.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/cli/impl/NetconfConfigGetCommand.java
index b7651a5..bac6bef 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/cli/impl/NetconfConfigGetCommand.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/cli/impl/NetconfConfigGetCommand.java
@@ -18,14 +18,13 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onosproject.netconf.DatastoreId.datastore;
 
-import java.io.IOException;
-
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.net.DeviceId;
 import org.onosproject.netconf.NetconfController;
 import org.onosproject.netconf.NetconfDevice;
+import org.onosproject.netconf.NetconfException;
 import org.onosproject.netconf.NetconfSession;
 
 /**
@@ -71,7 +70,7 @@
         try {
             String res = session.getConfig(datastore(cfgType.toLowerCase()));
             print("%s", res);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.error("Configuration could not be retrieved", e);
             print("Error occurred retrieving configuration");
         }
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
index 362cbac..f700768 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
@@ -24,8 +24,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-
 /**
  * Default implementation of a NETCONF device.
  */
@@ -54,7 +52,7 @@
         sessionFactory = new NetconfSessionMinaImpl.MinaSshNetconfSessionFactory();
         try {
             netconfSession = sessionFactory.createNetconfSession(deviceInfo);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             deviceState = false;
             throw new NetconfException("Cannot create connection and session for device " +
                                                deviceInfo, e);
@@ -78,7 +76,7 @@
         sessionFactory = factory;
         try {
             netconfSession = sessionFactory.createNetconfSession(deviceInfo);
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             deviceState = false;
             throw new NetconfException("Cannot create connection and session for device " +
                                                deviceInfo, e);
@@ -100,7 +98,7 @@
         deviceState = false;
         try {
             netconfSession.close();
-        } catch (IOException e) {
+        } catch (NetconfException e) {
             log.warn("Cannot communicate with the device {} session already closed", netconfDeviceInfo);
         }
     }
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
index bb1a4ed..e54e6cd 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
@@ -361,7 +361,7 @@
             try {
                 log.debug("Trying to reopen the Sesion with {}", deviceInfo.getDeviceId());
                 startSshSession();
-            } catch (IOException | IllegalStateException e) {
+            } catch (NetconfException | IllegalStateException e) {
                 log.debug("Trying to reopen the Connection with {}", deviceInfo.getDeviceId());
                 try {
                     connectionActive = false;
@@ -372,7 +372,7 @@
                         subscriptionConnected = false;
                         startSubscription(notificationFilterSchema);
                     }
-                } catch (IOException e2) {
+                } catch (NetconfException e2) {
                     log.error("No connection {} for device {}", netconfConnection, e.getMessage());
                     throw new NetconfException("Cannot re-open the connection with device" + deviceInfo, e);
                 }