Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling #35

Merged
merged 1 commit into from
Dec 24, 2024
Merged

Improve error handling #35

merged 1 commit into from
Dec 24, 2024

Conversation

JacobCallahan
Copy link
Owner

This change introduces a ton more situations where errors are passed up instead of resulting in an unrecoverable panic.

@JacobCallahan JacobCallahan added the enhancement New feature or request label Dec 24, 2024

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

src/connection.rs:327

  • The new error handling path introduced here is not covered by tests. Ensure that the error handling for scp_recv is tested.
let (mut remote_file, stat) = self.session.scp_recv(Path::new(&remote_path)).map_err(|e| PyErr::new::<PyIOError, _>(format!("Failed scp_recv: {}", e)))?;

src/connection.rs:334

  • The new error handling path introduced here is not covered by tests. Ensure that the error handling for File::create is tested.
let mut local_file = std::fs::File::create(&local_path).map_err(|e| PyErr::new::<PyIOError, _>(format!("File create error: {}", e)))?;

src/connection.rs:338

  • The new error handling path introduced here is not covered by tests. Ensure that the error handling for remote_file.read is tested.
let len = remote_file.read(&mut buffer).map_err(|e| PyErr::new::<PyIOError, _>(format!("Read error: {}", e)))?;

src/connection.rs:344

  • The new error handling path introduced here is not covered by tests. Ensure that the error handling for local_file.write_all is tested.
local_file.write_all(&buffer[..len]).map_err(|e| PyErr::new::<PyIOError, _>(format!("Write error: {}", e)))?;
This change introduces a ton more situations where errors are passed up
instead of resulting in an unrecoverable panic.
Copy link

@Copilot 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.

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

src/connection.rs:753

  • Using unwrap_or(0) here might mask an error. Consider handling the error explicitly.
self.last_pos = metadata.size.unwrap_or(0);

src/connection.rs:767

  • [nitpick] The error message 'Opening remote file failed' is not very informative. Consider providing more context about the error.
.expect("Opening remote file failed"),

tests/test_connection.py Show resolved Hide resolved
@JacobCallahan JacobCallahan merged commit 34ff62d into master Dec 24, 2024
15 checks passed
@JacobCallahan JacobCallahan deleted the errors branch December 24, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant