Skip to content

Conversation

@Rob-Hague
Copy link
Collaborator

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

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.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SftpException with StatusCode property and default messages for common status codes
  • Added Path property to SftpPathNotFoundException to capture the missing path
  • Renamed StatusCodes enum to StatusCode and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SftpPathNotFoundException doesn't contain the errored path Status codes returned by SFTP Server

2 participants