From 0a35a708f5ae5a5b9adefb3edb6ddd44c916f0d4 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sat, 24 Feb 2024 17:43:08 -0500 Subject: [PATCH] Adds prefix to xctFail on fail action. --- Sources/ComposableSubscriber/ReceiveReducer.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Sources/ComposableSubscriber/ReceiveReducer.swift b/Sources/ComposableSubscriber/ReceiveReducer.swift index 37111fc..f456176 100644 --- a/Sources/ComposableSubscriber/ReceiveReducer.swift +++ b/Sources/ComposableSubscriber/ReceiveReducer.swift @@ -80,23 +80,27 @@ extension Reducer { } public enum OnFailAction { - case xctFail + case xctFail(prefix: String? = nil) case handle((inout State, Error) -> Void) @usableFromInline func callAsFunction(state: inout State, error: Error) { switch self { - case .xctFail: - XCTFail("\(error)") + case let .xctFail(prefix): + if let prefix { + XCTFail("\(prefix): \(error)") + } else { + XCTFail("\(error)") + } case let .handle(handler): handler(&state, error) } } } -fileprivate extension WritableKeyPath { +extension WritableKeyPath { - func callAsFunction(root: inout Root, value: Value) { + public func callAsFunction(root: inout Root, value: Value) { root[keyPath: self] = value }