I'm trying to standardize the way I handle exceptions in my web application (homemade framework) but I'm not certain of the "correct" way to handle various situations. I'm wondering if there is a best practice from UI/ user-friendly point of view.
User logs into application and opens two tabs showing the same screen. On one tab they issue a delete command on object
FOO
. Then, in the other tab they then click the edit command onFOO
(which no longer exists); e.g. a GET request foreditObject.php?object_id=FOO
. What should I do when they issue the edit request for this nonexistent object?-Currently I am redirecting these "missing" objects to the previous page with an error message like "object does not exist".
User issues a GET request to search for Objects with
color=Red
, e.g.searchObjects.php?color=Red
. The query returning these results blew up because somebody dropped the OBJECTS table. This is an unexpected exception and isn't quite the same as 1).-Currently I am redirecting to
errorPage.php
with a message "Unexpected error"In general, what should I do if GET/POST parameters that should be there are instead mysteriously missing. Perhaps somebody is trying to inject something?
-Currently I am treating these the same as 2)
What should I be doing in each of the above 3 cases?
- Render a "Object does not exist" view at the url
editObject.php?object_id=FOO
- Redirect to a controller that displays an error view:
header('Location: errorPage.php')
- Serve a 404: not sure of the syntax for doing this in PHP/Apache
- Other