6

I am trying to figure out what the errors endpoint is used for, so I can I can implement it in my API.

I have been trying things like:

And I am getting a File Not Found Error in Firefox.

All the errors help page says is:

Summary
Simulates an error given a code

What are valid error codes? And, can we get some sort of response telling us that we supplied a bad error code?

2 Answers 2

7

The /errors method was requested to make it easier to test libraries. Finding questions/users/etc. that result in certain error cases can be... trying, and potentially quite brittle.

Defined Error Codes:

Invalid error codes result in a 404 error (NotFound).

2
2

Pass the parameter ?type=jsontext to see error JSON

http://api.stackoverflow.com/0.8/errors/404?type=jsontext

http://api.stackoverflow.com/0.8/errors/500?type=jsontext

Note: if you don't put ?type=jsontext, error code is simulated only in http response header, so firefox just give you error page.

2
  • This is incorrect, the JSON body is always returned. Firefox just doesn't show it to you by default. Either view source, or watch the HTTP traffic in a sniffer to see the error message. Commented Jun 1, 2010 at 6:55
  • @Kevin, You're right, I've crossed-out that part, my firefox just gave me alert Firefox can't find the file at http://api.stackoverflow.com/0.8/errors/4005., view-source was not viewable, so I assumed it was only in http headers. didn't watch with HTTP traffic, I stand corrected.
    – YOU
    Commented Jun 1, 2010 at 7:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .