Uh oh!
There was an error while loading. Please reload this page.
Add SftpException and SftpPathNotFoundException.Path - #1716
Conversation
This adds an SftpException which sits between the existing SftpPathNotFoundException/ SftpPermissionDeniedException and SshException, and which contains the response code from the SSH_FXP_STATUS packet, along with a default message if one was not provided. SftpPathNotFoundException also gains a Path property which is populated in cases where it makes sense.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new SftpException class as an intermediate exception type between existing SFTP-specific exceptions (SftpPathNotFoundException, SftpPermissionDeniedException) and the base SshException. The new exception includes a StatusCode property containing the response code from SSH_FXP_STATUS packets, along with default error messages when none are provided. Additionally, SftpPathNotFoundException now includes a Path property that captures the path that wasn't found.
Key changes:
- Introduced
SftpExceptionwithStatusCodeproperty and default messages for common status codes - Added
Pathproperty toSftpPathNotFoundExceptionto capture the missing path - Renamed
StatusCodesenum toStatusCodeand made it public (previously internal)
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| version.json | Bumped version from 2025.0.1 to 2025.1.0 to reflect the new feature |
| src/Renci.SshNet/Common/SftpException.cs | New exception class with StatusCode property and default message generation |
| src/Renci.SshNet/Common/SftpPathNotFoundException.cs | Changed to inherit from SftpException, added Path property and path-aware message generation |
| src/Renci.SshNet/Common/SftpPermissionDeniedException.cs | Changed to inherit from SftpException instead of SshException |
| src/Renci.SshNet/Sftp/StatusCode.cs | Renamed and made public with added documentation (first 9 status codes) |
| src/Renci.SshNet/Sftp/StatusCodes.cs | Removed (replaced by StatusCode.cs) |
| src/Renci.SshNet/Sftp/SftpSession.cs | Updated to use new SftpException and pass path context for better error messages |
| src/Renci.SshNet/Sftp/Responses/SftpStatusResponse.cs | Updated to use StatusCode enum and enabled nullable reference types |
| test files | Updated tests to verify new StatusCode property and Path property behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This adds an SftpException which sits between the existing SftpPathNotFoundException/SftpPermissionDeniedException and SshException, and which contains the response code from the SSH_FXP_STATUS packet, along with a default message if one was not provided.
SftpPathNotFoundException also gains a Path property which is populated in cases where it makes sense.
closes#161
closes#567