Skip to content
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

Goliath swallows server errors as 400 #50

Closed
gregwebs opened this issue May 16, 2011 · 6 comments
Closed

Goliath swallows server errors as 400 #50

gregwebs opened this issue May 16, 2011 · 6 comments

Comments

@gregwebs
Copy link
Contributor

I put a an exception in my response fail "WTF?"

Here is the output I see:

[2177:ERROR] 2011-05-16 14:24:50 :: WTF?
[2177:ERROR] 2011-05-16 14:24:50 :: ./epg.rb:184:in `response'
/home/gweber/.rvm/gems/ruby-1.9.2-p136/bundler/gems/goliath-dcf777db420c/lib/goliath/api.rb:155:in `block in call'
[2177:INFO] 2011-05-16 14:24:50 :: Status: 400, Content-Length: 16, Response Time: 76.87ms
[2177:INFO] 2011-05-16 14:24:50 :: Status: 400, Content-Length: 34, Response Time: 20.38ms

So there is a 400 instead of 500. This issue has also alerted me to the fact that I now see an extra 400 request tacked onto every request- not sure where I went wrong there :)

@gregwebs
Copy link
Contributor Author

Oh, so the extra 400 response is related to using a browser for an API that wants to give a JSON response. Still doesn't make a lot of sense to me though.

@dj2
Copy link
Contributor

dj2 commented May 16, 2011

If the browser is chrome, the second request is for favicon.ico usually.

@dj2
Copy link
Contributor

dj2 commented May 16, 2011

Exceptions are caught and handled by the API. The problem being, if you throw an exception inside the API it will end up in no-where land unless it's caught. The middlewares would have already returned at that point and the ASYNC_CALLBACK has to be used. So, we catch the exception, turn it into a 400 response, and fire the ASYNC_CALLBACKS.

We could possibly also stuff the exception into rack.exception so you can still access it if desired. Then, if you want, you can change the response in your async middleware for exceptions.

Would that work for you?

@gregwebs
Copy link
Contributor Author

Yes, I need access to the original exception, so rack.exception would be good. The other issue is the use of a 400 error code, which indicates a client error. In this case it should be a 500.

@dj2
Copy link
Contributor

dj2 commented May 16, 2011

K, feel free to move it to a 500 from a 400 and add in rack.exception.

@gregwebs
Copy link
Contributor Author

pull request in #51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants