Skip to content

Commit a658c10

Browse files
committed
Adopt typed-throws throughout Subprocess
Remove SubprocessError.UnderlyingError and instead use any Error for the .underlyingError field. This setup allows custom execution closures to throw any error and still be represented by a SubprocessError Raise macOS CI to 26.0 because we hit a mis-compile issue on 16.3
1 parent 94587eb commit a658c10

26 files changed

+1598
-1084
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
Invoke-Program swift test -c release
4343
Invoke-Program swift test --disable-default-traits
4444
enable_macos_checks: true
45-
macos_xcode_versions: '["16.3"]'
45+
macos_xcode_versions: '["26.0"]'
4646
macos_build_command: 'xcrun swift test && xcrun swift test -c release && xcrun swift test --disable-default-traits'
4747
enable_linux_static_sdk_build: true
4848
enable_android_sdk_build: true

Sources/Subprocess/API.swift

Lines changed: 302 additions & 159 deletions
Large diffs are not rendered by default.

Sources/Subprocess/AsyncBufferSequence.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,7 @@ extension AsyncBufferSequence {
275275
while let first = try await nextCodeUnit() {
276276
// Throw if we exceed max line length
277277
if case .maxLineLength(let maxLength) = self.bufferingPolicy, buffer.count >= maxLength {
278-
throw SubprocessError(
279-
code: .init(.streamOutputExceedsLimit(maxLength)),
280-
underlyingError: nil
281-
)
278+
throw SubprocessError.outputLimitExceeded(limit: maxLength)
282279
}
283280

284281
buffer.append(first)

Sources/Subprocess/Buffer.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ extension AsyncBufferSequence.Buffer {
7171
/// the method creates it. The argument is valid only for the duration of the
7272
/// closure's execution.
7373
/// - Returns: The return value of the body closure.
74-
public func withUnsafeBytes<ResultType>(
75-
_ body: (UnsafeRawBufferPointer) throws -> ResultType
76-
) rethrows -> ResultType {
77-
return try self.data.withUnsafeBytes(body)
74+
public func withUnsafeBytes<ResultType, Error: Swift.Error>(
75+
_ body: (UnsafeRawBufferPointer) throws(Error) -> ResultType
76+
) throws(Error) -> ResultType {
77+
do {
78+
return try self.data.withUnsafeBytes(body)
79+
} catch {
80+
throw error as! Error
81+
}
7882
}
7983

8084
#if SubprocessSpan

0 commit comments

Comments
 (0)