Re: Setting try and catch to use my own error handler

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

 



On Fri, 2006-10-20 at 15:50 +0900, Dave M G wrote:
> 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
> 

You are getting confused as to what an error handler is and what a
custom exception handler is.

You need to define a class that extends Exception to handle your
"errors" in that way.

class myExceptionHandler extends Exception {
    ...
    ...
    public function handleError($args)
    {
      //do something
    }
}

Then when you try and instantiate your object:

throw new myException("Your object is whack");

try {
     $obj = new Object();
}
catch(myException $e)
{
    myException::handleError();
}

--Paul

All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

-- 
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