Skip to content

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

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

Jeehut wants to merge 7 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 7 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.
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.

2 participants