What do you suppose is the nicest way to handle an "object not found" error?
For example, stackoverflow throws a 404 page not found. But really, I'm pretty sure it did find a page, it just didn't find a user with that id in the database. Would it be nicer to return a 404 status code, but use a custom error page saying the object wasn't found?
Is it possibly to return a sub-error code? ASP.NET has err开发者_如何转开发ors like 404.1
, but in terms of the actual HTTP status code, does it differ?
Custom error pages are a de-facto standard on serious sites. That said, there are myriads of error conditions for each of the dynamic pages - the user profile page can be missing an ID; answer a question page can be missing a question id; and so on.
It feels wasteful to try to create a custom error page that's designed specifically for each of these scenarios. Basically, you'd need one error page per a page of functionality.
What I do in my applications is send the user to a general-purpose error page, and output a custom message on that page that depends on the error condition.
精彩评论