Skip to content

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Sep 11, 2025

Motivation:

Users who want to use typed throws would benefit from us propagating the thrown error type through our APIs. Most of our surface doesn't allow for that because it relies on standard library APIs that haven't been updated, but we can do it for ByteBuffer which is entirely ours.

Modifications:

  • Adopt typed rethrows in ByteBuffer

Result:

Users have an easier time working with ByteBuffer

Motivation:

Users who want to use typed throws would benefit from us propagating
the thrown error type through our APIs. Most of our surface doesn't
allow for that because it relies on standard library APIs that
haven't been updated, but we can do it for ByteBuffer which is
entirely ours.

Modifications:

- Adopt typed rethrows in ByteBuffer

Result:

Users have an easier time working with ByteBuffer
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Sep 11, 2025
@Lukasa
Copy link
Contributor Author

Lukasa commented Sep 11, 2025

So this will be blocked behind us dropping 5.10.

@@ -426,8 +426,12 @@ extension ByteBuffer {
/// - Returns: The number of bytes read.
@discardableResult
@inlinable
public mutating func readWithUnsafeReadableBytes(_ body: (UnsafeRawBufferPointer) throws -> Int) rethrows -> Int {
let bytesRead = try self.withUnsafeReadableBytes({ try body($0) })
public mutating func readWithUnsafeReadableBytes<ErrorType: Error>(
Copy link
Member

Choose a reason for hiding this comment

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

NIT: In many other places the generic type is called Failure but not too important

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.

2 participants