Skip to content

Commit

Permalink
revert some unneeded change
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Oct 13, 2024
1 parent f5f0ffc commit 23cb8af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
3 changes: 3 additions & 0 deletions Lambdas/GHHooks/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ 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 {
case let .httpRequestFailed(response, file, line):
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")))"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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
}
}

0 comments on commit 23cb8af

Please sign in to comment.