Skip to content

Add error-chain indentation and explicit actor isolation - #44

Draft
Jeehut wants to merge 8 commits into
mainfrom
wip/error-chain-indent
Draft

Jeehut wants to merge 8 commits into
mainfrom
wip/error-chain-indent

Conversation

@Jeehut

@Jeehut Jeehut commented Oct 26, 2026

Copy link
Copy Markdown
Member

Summary

Adds an indent: overload for embedding error chains in indented text. Every line after the first receives the prefix, including multiline messages and Windows or Unicode line breaks.

ErrorKit.errorChainDescription(for: error, indent: "    ")
try await MyError.catch(isolation: #isolation) { /* actor-local operation */ }

Adds an explicit actor-isolated async catching overload. The original formatter and async catching signatures remain available. The contribution from #36 stays in the commit history, followed by separate adjustments.

The isolated overload accepts actor-local non-Sendable captures without adding @Sendable. A defaulted parameter on the original signatures was rejected because it breaks typed function references.

Draft status: Not approved for merge. The source-compatibility finding and compiler/platform gaps below remain open.

Source compatibility: let f = ErrorKit.errorChainDescription becomes ambiguous. Use ErrorKit.errorChainDescription(for:) or an explicit function type. This change is not fully source-compatible and needs a release-note migration warning.

Evidence

  • Before the newline repair: 14 failures, covering seven non-LF separators at two nesting depths. After: 32 tests in 7 suites passed, including all eight separators.
  • Tests ran with Apple Swift 6.4.2 on macOS arm64, using native SwiftPM and one build job. The final 32-test runs did not pass --parallel.
  • Negative controls detected lost actor isolation, wrong or double wrapping, and missing deep indentation. The restored implementation passed.
  • Typed legacy async and formatter function references passed regression tests. Empty indentation preserves the original formatter output.
  • DocC conversion exited 0. The generated pages resolved both formatter overloads and all three catching overloads. Unrelated DocC warnings remain.
  • Final external runtime recheck on 12ceaf82791448022c60bef20cf3cc6d53fb41ab: 149 checks passed, 0 failures, exit 0. The public-API client checked all eight separators, nested chains, empty lines, trailing separators, and multiline prefixes byte-for-byte. Scope: macOS arm64, Swift 6.4.2 Debug.
  • The --disable-testable-imports suite failed on the pre-existing @testable import in ThrowableTests.swift:3. It is not counted as passed.
  • Not checked: Swift 6.0, other platforms, Release optimization, or Thread Sanitizer. An existing mapper Sendable warning remains.

Merge Danger

Door: one-way (public API) · Blast Radius: ErrorKit clients.

Docs/Agents/BlastRadius.md is missing, so complete impact coverage is not established. Independent code reviews checked the API and the final newline repair. No release is part of this PR.

jubishop and others added 8 commits October 25, 2026 16:52
Calling `catch` from a @mainactor type or an actor failed under Swift 6 with
"sending value of non-Sendable type risks causing data races". #36 solved
this with `@Sendable`, but that rejects closures that capture non-Sendable
values, which compile fine today. Inheriting the caller's isolation via
`#isolation` fixes the actor case and keeps every existing call site working.

Co-authored-by: Justin Bishop <jubishop@gmail.com>
Keep the original async catch and error-chain formatter signatures so
existing typed function references compile. Require explicit arguments
for isolation and indentation on the additional overloads.

Retain actor-local closure coverage, add compilation regressions for
both function references, and distinguish all catch overloads in DocC.
ErrorKit targets the latest final Swift and Xcode. The macos-15 runner
still uses Xcode 16 with Swift 6.1, which rejects the isolation
forwarding in Catching.swift that Swift 6.4 accepts.

Run the tests on the xcode-27 runner and select Xcode 27.2 explicitly,
because that image still defaults to Xcode 27.1. Print the Swift
version so a failing run shows which compiler it used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants