Skip to content

Commit

Permalink
Update package
Browse files Browse the repository at this point in the history
  • Loading branch information
vmanot committed Jan 12, 2025
1 parent cfa56e9 commit cba369e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ extension ObservableTask {
/// - throws: An error indicating task failure or task cancellation.
public var value: Success {
get async throws {
try await successPublisher.output()
do {
let result: Success = try await successPublisher.output()

return result
} catch {
if let error = error as? ObservableTaskFailureProtocol {
if let unwrappedError: any Swift.Error = error._opaque_error {
throw unwrappedError
}
}

throw error
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ import Diagnostics
import Combine
import Swallow

protocol ObservableTaskFailureProtocol {
var _opaque_error: (any Swift.Error)? { get }
}

extension ObservableTaskFailure: ObservableTaskFailureProtocol {
public var _opaque_error: (any Swift.Error)? {
switch self {
case .canceled:
return nil
case .error(let error):
return error
}
}
}

/// An enumeration that represents the source of task failure.
@frozen
public enum ObservableTaskFailure<Error: Swift.Error>: _ErrorX, HashEquatable {
Expand Down

0 comments on commit cba369e

Please sign in to comment.