From 35a0b82c88c5c08999fbd21db2cf2687b583a97b Mon Sep 17 00:00:00 2001 From: Justin Bishop Date: Sat, 3 May 2025 16:13:55 -0700 Subject: [PATCH 1/2] Support error chain description with opening indent level --- Sources/ErrorKit/ErrorKit.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/ErrorKit/ErrorKit.swift b/Sources/ErrorKit/ErrorKit.swift index 277cfcb..1c14ba8 100644 --- a/Sources/ErrorKit/ErrorKit.swift +++ b/Sources/ErrorKit/ErrorKit.swift @@ -148,10 +148,12 @@ public enum ErrorKit { /// 2. Shows the underlying cause (DatabaseError.connectionFailed) /// 3. Provides the user-friendly message for context (users will report this) /// - /// - Parameter error: The error to describe, potentially containing nested errors + /// - Parameters: + /// - error: The error to describe, potentially containing nested errors + /// - indent: The initial indent string (normally "") /// - Returns: A formatted string showing the complete error hierarchy with indentation - public static func errorChainDescription(for error: Error) -> String { - return Self.chainDescription(for: error, indent: "", enclosingType: type(of: error)) + public static func errorChainDescription(for error: Error, indent: String = "") -> String { + return Self.chainDescription(for: error, indent: indent, enclosingType: type(of: error)) } private static func chainDescription(for error: Error, indent: String, enclosingType: Any.Type?) -> String { From 3b886cb3b1b83253b98296f699131b7f6837a7e8 Mon Sep 17 00:00:00 2001 From: Justin Bishop Date: Mon, 5 May 2025 10:38:02 -0700 Subject: [PATCH 2/2] make catch await a sendable closure --- Sources/ErrorKit/Catching.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ErrorKit/Catching.swift b/Sources/ErrorKit/Catching.swift index 9290d11..443a8b5 100644 --- a/Sources/ErrorKit/Catching.swift +++ b/Sources/ErrorKit/Catching.swift @@ -178,7 +178,7 @@ extension Catching { /// - Returns: The value returned by the operation if successful. /// - Throws: An instance of `Self` with the original error wrapped in the `caught` case. public static func `catch`( - _ operation: () async throws -> ReturnType + _ operation: @Sendable () async throws -> ReturnType ) async throws(Self) -> ReturnType { do { return try await operation()