sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
4k stars 931 forks source link

SftpPathNotFoundException doesn't contain the errored path #567

Open Deantwo opened 5 years ago

Deantwo commented 5 years ago

It is weird to debug an error throwing a Renci.SshNet.Common.SftpPathNotFoundException exception since it doesn't actually say what the path was.

It should be trivial to add another property to the SftpPathNotFoundException class and assign it in the constructor. Preferably the argument shouldn't be optional though.

Exception in my specific case is thrown from here:

Renci.SshNet.Common.SftpPathNotFoundException: No such file
     at Renci.SshNet.Sftp.SftpSession.RequestOpenDir(String path, Boolean nullOnError)
     at Renci.SshNet.Sftp.SftpSession.ChangeDirectory(String path)
     at Renci.SshNet.SftpClient.ChangeDirectory(String path)
     at <my code>

Finding the bug in my code isn't too hard, just requires me to add some more/better exception handling and logging of my ChangeDirectory call.

Deantwo commented 5 years ago

Could also add the path to the actual exception message.