Reputation: 7688
I am having a heavy issue with my web app when retrieving data through API from sources and is censored/deleted content because of how Google is interpreting it. According to google at my webmaster's panel :
Server error 18,216 errors
Not found 13,333 errors
Not followed 9 errors
Other 190 errors
In the live version of my app, I show returned errors by just doing (I'm using codeigniter):
show_error($e->getMessage());
I did so because I needed to show the error returned, from the source, without adding to much code, but I didn't thought of the negative effect it was to have later (I'm at my first published app, still have much to learn).
Right now I am working to a new release, but until then I was wondering which HTTP status code would be the appropriate one to use for a hot fix:
204 No Content
404 Not found
410 Gone
some other one?
There is no issue with the code or server, the HTTP Status Code 500 is generated because of show_error($e->getMessage());
and I want to use it the same way but adding an error code my self: show_error($e->getMessage(), 'error_general', 503);
because 500 is set as default:
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
Just to clarify things, I do not want to send a HTTP Status Code related to a restrict access/content but send a Code one related to the error message inside $e->getMessage()
, which 90% of the cases contains error message saying that the content was deleted or censored.
So that said, I ask: Which is the right HTTP Status Code to use when displaying an error message that says the content was either removed/censored or was set to unavailable because of X reason.
Upvotes: 2
Views: 3829
Reputation: 5971
If I understand you correctly, a user (or User-Agent) is trying to access something that used to be there but for all intents and purposes, is no longer available. It may exist somewhere on your server, but as far as the web is concerned it doesn't exist.
If that's the case, you have some choices, depending on what you want to communicate to the user:
Both 403 and 410 let the user know that it is some kind of legitimate path, but that you may never be able to GET the resource. For all three you may include an explanation in the body of the response (i.e. your error message).
Upvotes: 1
Reputation: 1306
A 5xx Error indicates the it has, something to do with the Server, which is clearly the case. When looking at the different status codes (http://httpstatus.es/), I would suggest 503: server is currently unavailable.
Upvotes: 0