-
Notifications
You must be signed in to change notification settings - Fork 16
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
Allow RequestHandler* to return subclasses of Response #29
Comments
@kmruiz Sounds good. WDYT @aleixmorgadas ? |
It looks great to me ^^ Does this improvement need a change on the |
@aleixmorgadas Probably we will need to change all the This would also be a really good opportunity for a one-time contribution, so I will label it. |
Definitely, let's help a new contributor join Vlingo ^^
…On Sun, Mar 3, 2019, 18:40 Kevin Mas Ruiz ***@***.***> wrote:
@aleixmorgadas <https://github.com/aleixmorgadas> Probably we will need
to change all the ResourceHandlers to force the return type to be
covariant because Java generics are invariant by default.
This would also be a really good opportunity for a one-time contribution,
so I will label it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFQzdQ1xxJzC4dJMHtD1E9EXKrLExPbPks5vTAkdgaJpZM4baFbs>
.
|
@kmruiz Would it be sufficient if we change edit: I believe that it won't be enough. Treating |
You are right, probably only changing the RequestHandler wouldn't be enough if we want the error handling also typesafe (as we don't have anything like ADTs sadly right now). I see two options, one is as you said, using something similar to Either. Right now we have Outcome<F, S> The other option would be to throw exceptions from the controller (Outcome<F, T> already supports that, using the get() method here) and use the error handler mechanism for those exception. What do you think @aantoniadis, @VaughnVernon , @aleixmorgadas ? |
I prefer the solution with |
IMO, it's worth to start adding @aantoniadis, glad you share your thoughts about how to design it ^^. I would suggest start with the simplest design to accomplish. We can do a If you think it's worth to do it in the same patch, up to you, just suggesting in case it helps to make smaller patches. You choose ^^ |
For edit: of course we can wrap the failure |
@aleixmorgadas @kmruiz ^^^ Please comment when possible. |
IMO, we shouldn't think about I, or someone, will explain later when I've more time, the reasons behind I wouldn't like to stop you to do the things you think are more appropriate to design this solution, I would say, share some ways this feature could be used to clarify your ideas with others if you think it's worth to, otherwise a Pull Request with the tests + implementation is enough. |
When we designed Even if I would agree that extending Throwable might not be needed always, having domain errors with the stack trace is really useful when logging. Also doesn't necessarilly pollute the hierarchy as it would be just the base trait of the ADT. In case that we want to change the signature of Do any of you see a way where we can start working on this task without changing |
I opened PR #30 in order to have some code as a reference for our discussion. The code is not ready to be merged. As you can see there, I had to wrap the errors in @aleixmorgadas I am not sure what you mean with your suggestion. Currently, On a different note, if we decide that |
@kmruiz Please see my #26 (comment) |
Solved by #26 |
With complex APIs is desirable to have more typesafe way of handling responses, because the response type can be seen as documentation. Consider this request handler:
It's would be impossible to know the response type before digging into the implementation (and taking a look at buildResponse). The suggested improvement would make explicit the response type:
WDYT?
The text was updated successfully, but these errors were encountered: