-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling Error #1
Comments
l don't know which project l used Observeable in, can you give me more information. I'm currently editing the project, if you have problem, let me know. |
#1 (comment) public struct AnyError<Failure: Error>: Error {
public var error: Failure
public init(error: Failure) {
self.error = error
}
}
public extension Error {
func asAnyError() -> AnyError<Self> {
AnyError(error: self)
}
}
extension AnyError: Equatable where Failure: Equatable {}
struct HttpError: Error, Equatable {
var errorString: String
}
enum MainAction: Equtable {
case responseTodo(Result<Data, AnyError<HttpError>>)
} |
I don't think it is better, do you have any idea? |
Now I get it, and both way are actually good, depends on the expected output maybe 😀. I think mine is more like that I want to show an error alert immediately rather than processing the response data, and so I could just focus on the error action of what the view should behave when an error is produced mean while yours like you want to show both error and data to user (?) |
My backend maybe return the Error in Result.success, you can check in here. |
Hi Nguyen, it's such a great example
But would you mind handling the error as well in the reducer when calling an API especially using Single instead Observeable
Thank you
The text was updated successfully, but these errors were encountered: