Exception::fillException() proposal
| From: | Antony Dovgal | Date: | Tue, 10 Jan 2006 13:42:56 +0000 |
| Subject: | Exception::fillException() proposal | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-21461@lists.php.net to get a copy of this message | ||
Hello all.
I'd like to propose addition of a new method of standard Exception class.
This method is somewhat identical to Java's fillInStackTrace() [0], but fills not only the
"trace", but also "line" and "file" properties.
See #33407 [1], this report explains how this method can be used.
Short example:
Exception::fillException() (the name is still under question) returns new exception object that can
be used this way:
<?php
try {
throw new Exception("message", 1);
} catch(Exception $e) {
throw $e->fillException();
}
?>
In the code above "line", "file" and "trace" properties will point at
the file/line where fillException() is called, not the file/line
where $e was constructed.
All the other properties of $e are copied, so they remain untouched.
See diff against HEAD in attachment.
[0] http://java.sun.com/j2se/1.3/docs/api/java/lang/Throwable.html#fillInStackTrace()
[1] http://bugs.php.net/bug.php?id=33407
--
Wbr,
Antony Dovgal