I'm working on a big website and was wondering what the best way to handle errors is. Should I create error messages the user can see (at least that way I can be notified)? should I hide them and write them in a log (I find that it's difficult to create helpful log entries - reinacting what came before the error isn't that easy)? should i redirect to the homepage on every error (could be annoying for th users)? what's the textbook approach?
You dont want to confuse members with difficult to understand errors, just make a quick error.html page and redirected users to that while logging the error at the same time.
Be sure to log the URL, the referring URL, the user ID (if logged in), the error type and error message. If necessary, serialize the $_POST array as well. This will help you figure out what happened.