extending Exception to allow for auto appending class name on exception message 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-&gt;solved = $solved;
      $this-&gt;howSolved = $howSolved;

      // make sure everything is assigned properly
      parent::__construct($message, $code, $previous);
   }

   public function setSolved($isSolved)
   {
      $this-&gt;solved = $isSolved;
   }

   public function setHowSolved($howSolved)
   {
      $this-&gt;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);
   }    
}
Changing an inherited method signature isn't a good idea. It means how you call a method changes depending on what exact class you're calling.

Exception::__construct has only 3 arguments, but the first of which can be anything. As such you could do:

class DataException extends Exception 
{
   protected $solved;
   protected $howSolved;

   public function __construct($message = null, $code = 0, Exception $previous = null)
    {
    $solved = $howSolved = false;
    if (is_array($message))  {
        $solved = $message['solved']; // message is an array
        ...
        $message = $message['message']; // and now it's a string to be used/compatible with the parent
    }


Which would work whether $message was a string or an array - and without changing the method signature.

Why do you have setters for properties on a exception? Sounds like you're using exceptions for something they aren't designed.