Got this idea from the php.net website on extending exceptions. The main thing I wanted with this was to have the exception name auto imprinted on the exception message, so I wouldn't have to write it in each message. So far its working, just wondering if this is efficient or not?
Thanks
class DataException extends Exception
{
protected $solved;
protected $howSolved;
public function __construct($message, $solved = false, $howSolved = null,
$code = 0, Exception $previous = null)
{
$this->solved = $solved;
$this->howSolved = $howSolved;
// make sure everything is assigned properly
parent::__construct($message, $code, $previous);
}
public function setSolved($isSolved)
{
$this->solved = $isSolved;
}
public function setHowSolved($howSolved)
{
$this->howSolved = $howSolved;
}
}
class GeoCoordinateOutOfBoundsException extends DataException
{
public function __construct($message, $solved = false, $howSolved = null,
$code = 0, Exception $previous = null)
{
$message = get_class($this) . "::" . $message;
// make sure everything is assigned properly
parent::__construct($message, $solved, $howSolved, $code, $previous);
}
}