Skip to content

Commit

Permalink
refactor: use Result for helixTask callback
Browse files Browse the repository at this point in the history
  • Loading branch information
LosFarmosCTL committed Jul 11, 2024
1 parent 23eaee7 commit b145d56
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/Twitch/Helix/TwitchClient+Helix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ extension TwitchClient {

public func helixTask<R, H: Decodable>(
for endpoint: HelixEndpoint<R, H, HelixEndpointResponseTypes.Normal>,
completionHandler: @escaping @Sendable (R?, HelixError?) -> Void
completionHandler: @escaping @Sendable (Result<R, HelixError>) -> Void
) {
Task {
do {
let result = try await self.helix(endpoint: endpoint)
completionHandler(result, nil)
completionHandler(.success(result))
} catch let error as HelixError {
completionHandler(nil, error)
completionHandler(.failure(error))
}
}
}
Expand Down

0 comments on commit b145d56

Please sign in to comment.