Skip to content

Conversation

dnadoba
Copy link
Collaborator

@dnadoba dnadoba commented Apr 13, 2023

Motivation

A users might want to provide more information why a request got cancelled. For example if we cancel a file download because the response status code is not 2xx, it is desirable to propagate which status code was returned.

Modification

  • add Task.fail(_:) in addition to Task.cancel() that takes a custom Error which is used to complete the underlying request promise.

Result

Improved error messages.

@dnadoba dnadoba added the 🆕 semver/minor Adds new public API. label Apr 13, 2023
Copy link
Member

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Splendid, thank you!

Copy link
Collaborator

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Really nice change, I like this a lot.

@Lukasa Lukasa merged commit b9029ef into swift-server:main Apr 13, 2023
@dnadoba dnadoba deleted the dn-custom-request-cancel-error branch April 13, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants