Page MenuHomePhabricator

D20143.id48087.diff
No OneTemporary

D20143.id48087.diff

diff --git a/src/error/PhutilProxyException.php b/src/error/PhutilProxyException.php
--- a/src/error/PhutilProxyException.php
+++ b/src/error/PhutilProxyException.php
@@ -11,10 +11,15 @@
private $previousException;
- public function __construct($message, Exception $previous, $code = 0) {
+ public function __construct($message, $previous, $code = 0) {
$this->previousException = $previous;
- if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ // This may be an "Exception" or a "Throwable". The "__construct()" method
+ // for the Exception is documented as taking an Exception, not a Throwable.
+ // Although passing a Throwable appears to work in PHP 7.3, don't risk it.
+ $is_exception = ($previous instanceof Exception);
+
+ if (version_compare(PHP_VERSION, '5.3.0', '>=') && $is_exception) {
parent::__construct($message, $code, $previous);
} else {
parent::__construct($message, $code);
diff --git a/src/error/phlog.php b/src/error/phlog.php
--- a/src/error/phlog.php
+++ b/src/error/phlog.php
@@ -21,7 +21,7 @@
foreach (func_get_args() as $event) {
$data = $metadata;
- if ($event instanceof Exception) {
+ if (($event instanceof Exception) || ($event instanceof Throwable)) {
$type = PhutilErrorHandler::EXCEPTION;
// If this is an exception, proxy it and generate a composite trace which
// shows both where the phlog() was called and where the exception was

File Metadata

Mime Type
text/plain
Expires
Fri, May 17, 10:59 PM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6273380
Default Alt Text
D20143.id48087.diff (1 KB)

Event Timeline