@@ -139,7 +139,7 @@ public Device(JSch sshClient,
139139 try {
140140 builder = factory .newDocumentBuilder ();
141141 } catch (ParserConfigurationException e ) {
142- throw new NetconfException (String .format ("Error creating XML Parser: %s" , e .getMessage ()));
142+ throw new NetconfException (String .format ("Error creating XML Parser: %s" , e .getMessage ()), e );
143143 }
144144
145145 this .netconfCapabilities = (netconfCapabilities != null ) ? netconfCapabilities : getDefaultClientCapabilities ();
@@ -190,7 +190,7 @@ private NetconfSession createNetconfSession() throws NetconfException {
190190 sshClient .setKnownHosts (hostKeysFileName );
191191 }
192192 } catch (JSchException e ) {
193- throw new NetconfException (String .format ("Error loading known hosts file: %s" , e .getMessage ()));
193+ throw new NetconfException (String .format ("Error loading known hosts file: %s" , e .getMessage ()), e );
194194 }
195195 sshClient .setHostKeyRepository (sshClient .getHostKeyRepository ());
196196 log .info ("Connecting to host {} on port {}." , hostName , port );
@@ -203,7 +203,7 @@ private NetconfSession createNetconfSession() throws NetconfException {
203203 try {
204204 sshSession .setTimeout (connectionTimeout );
205205 } catch (JSchException e ) {
206- throw new NetconfException (String .format ("Error setting session timeout: %s" , e .getMessage ()));
206+ throw new NetconfException (String .format ("Error setting session timeout: %s" , e .getMessage ()), e );
207207 }
208208 if (sshSession .isConnected ()) {
209209 log .info ("Connected to host {} - Timeout set to {} msecs." , hostName , sshSession .getTimeout ());
@@ -231,7 +231,7 @@ private Session loginWithUserPass(int timeoutMilliSeconds) throws NetconfExcepti
231231 return session ;
232232 } catch (JSchException e ) {
233233 throw new NetconfException (String .format ("Error connecting to host: %s - Error: %s" ,
234- hostName , e .getMessage ()));
234+ hostName , e .getMessage ()), e );
235235 }
236236 }
237237
@@ -266,7 +266,7 @@ private void loadPrivateKey() throws NetconfException {
266266 try {
267267 sshClient .addIdentity (pemKeyFile );
268268 } catch (JSchException e ) {
269- throw new NetconfException (String .format ("Error parsing the pemKeyFile: %s" , e .getMessage ()));
269+ throw new NetconfException (String .format ("Error parsing the pemKeyFile: %s" , e .getMessage ()), e );
270270 }
271271 }
272272
@@ -332,7 +332,7 @@ public String runShellCommand(String command) throws IOException {
332332 try {
333333 channel = (ChannelExec ) sshSession .openChannel ("exec" );
334334 } catch (JSchException e ) {
335- throw new NetconfException (String .format ("Failed to open exec session: %s" , e .getMessage ()));
335+ throw new NetconfException (String .format ("Failed to open exec session: %s" , e .getMessage ()), e );
336336 }
337337 channel .setCommand (command );
338338 InputStream stdout ;
@@ -347,7 +347,7 @@ public String runShellCommand(String command) throws IOException {
347347 try {
348348 line = bufferReader .readLine ();
349349 } catch (Exception e ) {
350- throw new NetconfException (e .getMessage ());
350+ throw new NetconfException (e .getMessage (), e );
351351 }
352352 if (line == null || line .equals (NetconfConstants .EMPTY_LINE ))
353353 break ;
@@ -377,7 +377,7 @@ public BufferedReader runShellCommandRunning(String command)
377377 try {
378378 channel = (ChannelExec ) sshSession .openChannel ("exec" );
379379 } catch (JSchException e ) {
380- throw new NetconfException (String .format ("Failed to open exec session: %s" , e .getMessage ()));
380+ throw new NetconfException (String .format ("Failed to open exec session: %s" , e .getMessage ()), e );
381381 }
382382 InputStream stdout = channel .getInputStream ();
383383 return new BufferedReader (new InputStreamReader (stdout , Charset .defaultCharset ()));
0 commit comments