Setting try and catch to use my own error handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PHP List,

I have a system where the code parses the URL and creates objects based on the classes named in the link.

In order to prevent a user typing in a URL that contains an object that doesn't exist, and getting an error, I'm trying to set up an error handler class, called ErrorHandler, that will handle it.

I set the error handler to be my own, and then put a Try and Catch around the part of the code that

set_error_handler(ErrorHandler::handleError());
try
{
object = new $urlParts[0]();
if (!empty($urlParts[2]))
{
$object->$urlParts[1]($urlParts[2]);
}
else
{
$object->$urlParts[1]();
}
}
catch (Error $e)
{
echo "Sorry, the web page you are looking for can not be found.";
}


Inside my ErrorHandler, I have this:
public static function handleError($errno, $errstr, $errfile, $errline)
{
echo "Hey dude! Error! " . $errno . $errstr . $errfile . $errline ;
}

However, I get errors saying that the arguments for handleError don't exist.

Shouldn't they be automatically passed to my own error handler?

Thank you for any advise.

--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux