From 5cf20a1ed3beb18ecbf491b11c521771d311a438 Mon Sep 17 00:00:00 2001 From: Vladislav Kiryukhin Date: Sun, 6 Nov 2022 15:56:04 +0400 Subject: [PATCH 1/2] Make isTopLevelFailure optional --- Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift | 2 +- Sources/XCResultKit/Schema/ActionTestFailureSummary.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift b/Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift index 1e7ffad..bd1e32c 100644 --- a/Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift +++ b/Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift @@ -27,7 +27,7 @@ public struct ActionTestExpectedFailure: XCResultObject { uuid = xcOptional(element: "uuid", from: json) failureReason = xcOptional(element: "failureReason", from: json) failureSummary = xcOptional(element: "failureSummary", from: json) - isTopLevelFailure = try xcRequired(element: "isTopLevelFailure", from: json) + isTopLevelFailure = xcOptional(element: "isTopLevelFailure", from: json) ?? false } catch { logError("Error parsing ActionTestExpectedFailure: \(error.localizedDescription)") return nil diff --git a/Sources/XCResultKit/Schema/ActionTestFailureSummary.swift b/Sources/XCResultKit/Schema/ActionTestFailureSummary.swift index 665cd10..1734fa6 100644 --- a/Sources/XCResultKit/Schema/ActionTestFailureSummary.swift +++ b/Sources/XCResultKit/Schema/ActionTestFailureSummary.swift @@ -49,7 +49,7 @@ public struct ActionTestFailureSummary: XCResultObject { associatedError = xcOptional(element: "associatedError", from: json) sourceCodeContext = xcOptional(element: "sourceCodeContext", from: json) timestamp = xcOptional(element: "timestamp", from: json) - isTopLevelFailure = try xcRequired(element: "isTopLevelFailure", from: json) + isTopLevelFailure = xcOptional(element: "isTopLevelFailure", from: json) ?? false } catch { logError("Error parsing ActionTestExpectedFailure: \(error.localizedDescription)") return nil From 241748abffa161006884cd300a184d3537dcd7af Mon Sep 17 00:00:00 2001 From: Vladislav Kiryukhin Date: Sun, 6 Nov 2022 16:07:30 +0400 Subject: [PATCH 2/2] Remove do-catch and fix warning --- .../Schema/ActionTestExpectedFailure.swift | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift b/Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift index bd1e32c..534a219 100644 --- a/Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift +++ b/Sources/XCResultKit/Schema/ActionTestExpectedFailure.swift @@ -22,15 +22,10 @@ public struct ActionTestExpectedFailure: XCResultObject { public let failureSummary: ActionTestFailureSummary? public let isTopLevelFailure: Bool - public init?(_ json: [String: AnyObject]) { - do { - uuid = xcOptional(element: "uuid", from: json) - failureReason = xcOptional(element: "failureReason", from: json) - failureSummary = xcOptional(element: "failureSummary", from: json) - isTopLevelFailure = xcOptional(element: "isTopLevelFailure", from: json) ?? false - } catch { - logError("Error parsing ActionTestExpectedFailure: \(error.localizedDescription)") - return nil - } + public init(_ json: [String: AnyObject]) { + uuid = xcOptional(element: "uuid", from: json) + failureReason = xcOptional(element: "failureReason", from: json) + failureSummary = xcOptional(element: "failureSummary", from: json) + isTopLevelFailure = xcOptional(element: "isTopLevelFailure", from: json) ?? false } }