- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Yeah, the story was not TRWTF, nor is Fails.
What's TRWTF is that this code is following the convention, as established by 99% of web devs, to return HTTP error codes based on however the guy who wrote the code they copied and pasted did it.
Admin
[quote user="noland"][quote user="Tyler"]In case you want to distinguish this from the other 404-case: What about 406 "Not Acceptable"?[/quote] 406 should be returned if the client told the server which formats it accepts, and the response that the server wants to return doesn't fit those formats. For example, if the client requested response with a charset that the server doesn't support, or with a mime type that the server doesn't support.
The "Not acceptable" refers to the client. The server could give a reply, but the reply wouldn't be acceptable to the client.
But really, anyone writing this kind of code should learn about what they are doing (entering "error 406" into Google is all you need), and think about what a client would do depending on the error code. If I write client code and get an error 406, I'd send an "Accept: /" header and then be very confused if it still doesn't work.
Admin
Ruby on Rails blows. Plain and simple. Most RoR programmers are hacks that couldn't code their way out of a wet paper bag.
Admin
Admin
Admin
Admin
TRWTF is not indenting code.
Admin
Admin
Do not return "oops, my service broke down, retry later" (500), if a parameter was empty.
Do not return "please supply a valid HTTP-user" (401), if your request for "http://example.com/users/user1/unique" doesn't match with an ID "user1" in your DB, but you would have a valid ID "user2" and would accept "http://user2:@example.com/users/user1/unique" as a valid request.
Rather return a JSON object (or alike) with your own status-property. Suggesting 406 was just another example in goofiness.
Admin
[Citation needed]
(hey! that works on more than one level!)
Admin
Admin
Convention, configuration, it don't matter one bit to me son. All you need to know is that Error 316 says I just whooped your ass.
Admin
Actually, returning error numbers when things go wrong and data when things work fine is just a convention. You don't really have to do things that way.
Admin
I'll throw in a -1 since the author treats Ruby and Ruby on Rails as synonyms. Every instance of 'Ruby' after the string 'local Ruby expert' should be replaced with 'Rails'.
But I did enjoy the explanation.
Admin
Conventions should only be used if they happen to be in Vegas and are looking for a good time. Otherwise, let the intern deal with it.
Admin
+1
It amazes me how people who work with a particular protocol every day aren't even familiar with it's basic standards.
Admin
You clearly don't know what "authorization" means.
You don't know what "resource" means, either. It refers to the user object, not the Ruby function that handles it.
Admin
Admin
If you don't like the content type, I believe the correct code is 406. Returning a 401 when the content type is not json would mean "you have asked for a word document, but before I can do anything for you I need you to log in".
Admin
Such as its/it's?
Admin
Replying to [Citation needed] with a wikipedia link just might make the internet explode, but let's give it a go.
http://en.wikipedia.org/wiki/420_%28cannabis_culture%29
420, 4:20, or 4/20 (pronounced four-twenty) is a code-term used primarily in North America that refers to the consumption of cannabis and by extension, as a way to identify oneself with cannabis subculture or simply cannabis itself.
Origins
A widely discussed story says that a group of teenagers in San Rafael, California, calling themselves the Waldos, because, "their chosen hang-out spot was a wall outside the school", used the term in connection with a fall 1971 plan to search for an abandoned cannabis crop that they had learned about. The Waldos designated the Louis Pasteur statue on the grounds of San Rafael High School as their meeting place, and 4:20 p.m. as their meeting time.
Admin
You misunderstood my comment. I was saying that in reference to the fact that I wanted to back up what was said about the sign post with an article showing that it did indeed happen in Colorado.
Admin
It happened in Washington.
It's even written in the Bible: Adulterers should be stoned.
Admin
Since 500 isn't an application error, I was going to suggest that it should be an error for the application to attempt to return a 500 error, but I'm worried that the correct error for the server to return for "application erroneously attempting to return 500 error" is 500...