Re: Bug #64910: Line number of $e = new Exception vs. line number of throw $e

From: Date: Fri, 24 May 2013 14:36:52 +0000
Subject: Re: Bug #64910: Line number of $e = new Exception vs. line number of throw $e
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-67490@lists.php.net to get a copy of this message
> Also, throwing new exception with previous is not the same as throwing > the same exception twice. Correct, but I've personally never thrown the same exception twice. The only times I've thrown exceptions from catch blocks is to provide a better exception or perhaps to abstract away something in the implementation. For instance, if I hit a PDO exception in my data access then I'll catch it somewhere higher in the structure and throw a GatewayException instead. Likewise, if the data was coming from The Cloud and I couldn't access it for some reason I'd throw the GatewayException. This way when someone uses the gateway the implementation doesn't leak. This is the only time I've thrown exceptions in a catch block. This is an interesting 'bug' or 'feature' or whatever you want to call it. I wouldn't say the current way is wrong, but a naive approach would have some interesting issues as well. More than anything I think we just need to decide what we want the behavior to be a document the resulting quirks.

« previous php.internals (#67490) next »