Re: Exception::getLine()

From: Date: Thu, 19 May 2016 19:47:41 +0000
Subject: Re: Exception::getLine()
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-93402@lists.php.net to get a copy of this message
On 19/05/2016 19:35, Rasmus Schultz wrote:
Technically, every throw is a new exception "flow" - even if you're > recycling the Exception instance, it's the throw statement that > starts the unique stack unwind from the throw site; it's where the > action happens.
That's one interpretation, but it doesn't really hold up in all cases. Consider a catch statement that needs to filter more granularly than the class name; since you already mentioned PDO, I'll make an example with that: catch ( PDOException $e ) {
    if ( substr($e->getCode(), 0, 2) === '08' ) {
        $this->reconnect();
    } else {
        throw $e;
    }
} Of what value to a subsequent catch statement is the trace of that throw statement? And why does that "start a new exception flow", but if PDO threw different sub-classes, you could let one flow through unmodified by tightening the catch statement? Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#93402) next »