From 23cb8afb142e93585a989436ff9c5aa176a03aff Mon Sep 17 00:00:00 2001 From: MahdiBM Date: Sun, 13 Oct 2024 15:44:04 +0330 Subject: [PATCH] revert some unneeded change --- Lambdas/GHHooks/Errors.swift | 3 +++ .../GHHooks/Extensions}/+TaskGroup.swift | 20 +------------------ 2 files changed, 4 insertions(+), 19 deletions(-) rename {Sources/Shared => Lambdas/GHHooks/Extensions}/+TaskGroup.swift (63%) diff --git a/Lambdas/GHHooks/Errors.swift b/Lambdas/GHHooks/Errors.swift index 4bc15b91..844baf29 100644 --- a/Lambdas/GHHooks/Errors.swift +++ b/Lambdas/GHHooks/Errors.swift @@ -8,6 +8,7 @@ import Foundation enum Errors: Error, CustomStringConvertible, LocalizedError { case httpRequestFailed(response: any Sendable, file: String = #filePath, line: UInt = #line) case headerNotFound(name: String, headers: AWSLambdaEvents.HTTPHeaders) + case multipleErrors(errors: [any Error]) var description: String { switch self { @@ -15,6 +16,8 @@ enum Errors: Error, CustomStringConvertible, LocalizedError { return "httpRequestFailed(response: \(response), file: \(file), line: \(line))" case let .headerNotFound(name, headers): return "headerNotFound(name: \(name), headers: \(headers))" + case let .multipleErrors(errors): + return "multipleErrors(errors: \(errors.map({ String(reflecting: $0) }).joined(separator: ";\n")))" } } diff --git a/Sources/Shared/+TaskGroup.swift b/Lambdas/GHHooks/Extensions/+TaskGroup.swift similarity index 63% rename from Sources/Shared/+TaskGroup.swift rename to Lambdas/GHHooks/Extensions/+TaskGroup.swift index 844dd58f..41479596 100644 --- a/Sources/Shared/+TaskGroup.swift +++ b/Lambdas/GHHooks/Extensions/+TaskGroup.swift @@ -1,5 +1,3 @@ -import Foundation - /// Accumulates errors while performing the tasks concurrently. /// The primary purpose of this is so e.g. if the first task fails, the next tasks still run. package func withThrowingAccumulatingVoidTaskGroup( @@ -22,23 +20,7 @@ package func withThrowingAccumulatingVoidTaskGroup( } guard errors.isEmpty else { - throw MultipleErrors(errors) + throw Errors.multipleErrors(errors) } } } - -struct MultipleErrors: CustomStringConvertible, LocalizedError { - let errors: [any Error] - - init(_ errors: [any Error]) { - self.errors = errors - } - - var description: String { - "MultipleErrors { \(errors.map({ String(reflecting: $0) }).joined(separator: "; ")) }" - } - - var errorDescription: String? { - self.description - } -}