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
Proposal: error handling with generic parameter #39
Comments
Looks cool :) |
Yes, i proposed catch operator as an overloaded function. .catch { (error: MyError) in
// compiler picks generic catch operator.
}
.catch { (error: Error) in
// compiler picks default catch. because generic type does not supports protocol.
}
.catch { error in
// same as "error: Error"
} also i made a pull requests, please review :) |
@gloooooooomy thank you, I love your proposal! Just have a concern with the case like the following: enum CustomError: Error { case test }
Promise<Void> {
throw Test.Error.code42
}.then { _ in
XCTFail()
}.catch { error in
XCTAssertTrue(error == CustomError.test) // Never executed.
} I imagine, it's expected that the Ideally, we'd want something like default generic arguments be implemented in Swift to have only one version of What do you think? |
@gloooooooomy let's close this issue for now, but don't hesitate to follow up if you have any ideas on how to deal with the current compiler limitations. |
@shoumikhin sorry for reply too late. :( |
Hello :)
Idea : make a overloaded catch function with generic parameter
and using like
instead of
The text was updated successfully, but these errors were encountered: