-
Notifications
You must be signed in to change notification settings - Fork 328
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
Support status 500 #926
Support status 500 #926
Conversation
You need this to use with services or something? (because we typically only throw |
Hi Turini, Yes I need it. If you are using a micro services architecture, your
|
Sure, it makes sense for me (explicitly sending an 500 status code). |
Ok, thank you! Let's wait for more reviews.
|
I disagree. So throwing an Exception is one correct way of modeling it, specially because the client can't do anything about it. |
Lucas, if you are the server and need to consume a 3rd party API. You know We cant just thrown an exception without anyone to catch it, expecting
|
Do you want to return 500 with an empty response? If we want to add this method, we need to serialize something. Otherwise letting the exception blow up will return 500 with the 500 page configured on the server, that's almost equivalent to having an empty response. Can you add a cookbook with the exception interceptor you have in mind? Serializing something about the interceptor in JSON, for example. |
@lucascs Actually, in my use case, I want to return an empty response. But I want to log the error and be explicit in my code that I'm returning 500 as response. I think that just throwing an exception without anyone to handle it can confuse other developers. They will think: "what's happening with this exception? Who catch this? What's the response after this?" About the 500 page, the server will not render it because the client will ask for a JSON with the header |
There are two types of exceptions: recoverable and not recoverable Anyway, not opposed to add this method, but it would be nice to have the docs/cookbook along with the PR. |
Do we have docs for others statuses?
|
oops, sorry |
Do you guys think that makes sense to send a 502 response to the client? 10.5.3 502 Bad Gateway |
I think that makes sense. Indeed, I think that VRaptor's users should be able to return any status that they want to. We have many scenarios in web applications and thinking about REST services we are using HTTP status codes more and more. |
I think you can do something like result.use(Results.http()).status(xxx). On Fri Jan 16 2015 at 2:40:26 PM Nykolas Laurentino de Lima <
|
@csokol but if we already have |
Ok, I think that makes sense to create this new method. But then I think we On Fri Jan 16 2015 at 2:52:31 PM Nykolas Laurentino de Lima <
|
I think this will be the right think to do! |
We have almost a hundred http status codes. So will be too hard to add all these codes as methods. You can use |
I agree with you Otavio. But i think we can implement the most common
|
Sink or swim? I don't think we should add all the other response codes until
For me it makes sense to send an exception when something goes wrong... |
We already have: |
@garcia-jj I know we have |
@nykolaslima I know the goal of this pull request. I'm only answering your previously question that is:
And my anwer is: we already have. |
@garcia-jj I see your point but I believe that status 500 is a common status and IMHO it should be in |
About this point, I agree with @lucascs. Application should send only |
@garcia-jj but don't you think that throwing an exception explicit that you know that no body is gonna catch is a good think? |
Throwing an exception, IMHO, is better because all servlet implementations converts exceptions in a |
I disagree because throwing an exception with nobody to catch is a bad But anyway, if nobody is against to add this new method, can we merge it?
|
+1 to merge it and be happy :) that's just about adding a new short way to send |
+1 merge Em 12:22 dom, 18/01/2015, Rodrigo Turini notifications@github.com
|
🚢 |
Thank you, @nykolaslima! |
❤️ 💛 |
closes #912