Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jpdillingham
Copy link
Member

Closes #1541

Copy link
Contributor

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 refactors error handling in transfer services by introducing a centralized TryFail method to eliminate duplicate code. The changes consolidate repetitive error-handling logic that was previously scattered across multiple catch blocks in both UploadService and DownloadService.

  • Introduces public TryFail(Guid id, Exception exception) method to both Upload and Download service interfaces
  • Adds private TryFail(Guid id, string exception, TransferStates state) overload in UploadService for custom error messages
  • Refactors exception handling in catch blocks and task continuations to use the new methods
  • Implements idempotent behavior ensuring transfer state is only updated once

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/slskd/Transfers/Uploads/UploadService.cs Adds TryFail methods and refactors exception handling in catch blocks (NotFoundException, OperationCanceled/Timeout, generic exceptions) and failure paths in task continuations and enqueue operations
src/slskd/Transfers/Downloads/DownloadService.cs Refactors existing TryFail method to wrap Update call in try-catch for consistent error handling with proper return values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jpdillingham jpdillingham merged commit 7450257 into master Nov 28, 2025
6 checks passed
@jpdillingham jpdillingham deleted the tryfail branch November 28, 2025 23:43
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.

Replicate TryFail() from downloads to uploads

2 participants