Passing variables/values to custom exception?
<p>Is this how you would pass a value ("username" in example below) to a custom exception? The question being Would I use <code>__construct()</code>? Is using a custom exception for checking whether an important variable is set an overkill?</p>

<pre><code>class customException extends Exception {

    public function __construct($e) {
        parent::__construct($e); // makes sure variable is set? [1]
        $this-&gt;e = $e;
    }
    public function redirect_user() {
        if($this-&gt;e === "username") {
            header("Location: ");
        }
    }
}

class testing {

    public function test() {
        try {
            if(!isset($_POST['username'])) {
                throw new customException("username");
            }
        }
        catch(customException $e) {
            $e-&gt;redirect_user();
        }
    }
}
</code></pre>

<p>[1] <a href="http://php.net/manual/en/language.exceptions.extending.php#example-266" rel="nofollow">http://php.net/manual/en/language.exceptions.extending.php#example-266</a></p>

<p>On a side note, what's the purpose of <code>parent::__construct($e)</code>? Wouldn't that be redundant?</p>
