class PLException extends Exception { protected $messages = array( ); public function __construct($code) { $args = func_get_args(); array_shift($args); if (array_key_exists($code, $this->messages)) { $message = vsprintf($this->messages[$code], $args); } else { $message = "Unknown error ".$code; } parent::__construct($message, $code); } } class PLConfigException extends PLException { protected $messages = array( 1 => "Couldn't open \"%s\" for reading", 2 => "Invalid configuration option \"%s\" in %s, line %s", ); }