Re: Exception::getLine()

From: Date: Thu, 19 May 2016 11:58:17 +0000
Subject: Re: Exception::getLine()
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-93397@lists.php.net to get a copy of this message
On 19.05.2016 13:14, Rasmus Schultz wrote: > I know that I can dig in via e.g. > Exception::getStackTrace()[0]["line"] and pull the relevant > line-number myself, but I'm wondering why the line-number 2 is > relevant, important or interesting at all? If you are rethrowing exceptions inside the catch bloc: for ($code = 0; $code < 2; $code++) { try { throw new Exception('Message '.$code, $code); } catch (\Exception $e) { if ($e->getCode() > 0) { throw $e; } } } Inside the catch bloc I check whether the Exception code is one that can be handled at that place (code = 0), if not I rethrow the exception. If the line property would refer to the place where the exception was thrown I'd lose information in that case. Tim

« previous php.internals (#93397) next »