Hey all, i've just started to use the exception suite instead of the normal PHP error suite. For those of you looking for an object orientated way to do this without looking down at Glen and Sean's examples (Lesson 1: ALWAYS read the logs!), here you go:
<?php
class NewException extends Exception
{
public function __construct($message, $code=NULL)
{
parent::__construct($message, $code);
}
public function __toString()
{
return "Code: " . $this->getCode() . "<br />Message: " . htmlentities($this->getMessage());
}
public function getException()
{
print $this; }
public static function getStaticException($exception)
{
$exception->getException(); }
}
set_exception_handler(array("NewException", "getStaticException"));
throw new NewException("Catch me!!!", 69);
?>
Let me know if i'm missing something obvious as I left my glasses at home and I just came back from the Melbourne cup (If I won then I wouldn't be at work still!).