I was working on the Kish Twitter plugin which is a Wordpress Twitter Plugin was getting some errors when the Twitter API was down or there were some issues when parsing the Search RSS feeds. I thought of displaying a custom Error message rather than the PHP error. Its always good to use custom error handling so that the web page does not break up or create a bad impression on your visitor.
We create a custom error handling function which is called when ever an error is triggered and displays the custom error message.
This function must be able to handle a minimum of two parameters (error level and error message) but can accept up to five parameters (optionally: file, line-number, and the error context):
function kish_Error_handler($errno, $errstr) {
echo "<b>Error:</b> [$errno] $errstr<br />";
echo "There was an error while processing your request";
}
// call this inside the function to handle the error
set_error_handler("kish_Error_handler");
You can find more about PHP Error Handling here.
