Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14060790
D12796.id30910.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12796.id30910.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -543,7 +543,10 @@
'PhutilAWSException' => 'Exception',
'PhutilAWSFuture' => 'FutureProxy',
'PhutilAWSS3Future' => 'PhutilAWSFuture',
- 'PhutilAggregateException' => 'Exception',
+ 'PhutilAggregateException' => array(
+ 'Exception',
+ 'Iterator',
+ ),
'PhutilAllCapsEnglishLocale' => 'PhutilLocale',
'PhutilAmazonAuthAdapter' => 'PhutilOAuthAuthAdapter',
'PhutilArgumentParserException' => 'Exception',
diff --git a/src/error/PhutilAggregateException.php b/src/error/PhutilAggregateException.php
--- a/src/error/PhutilAggregateException.php
+++ b/src/error/PhutilAggregateException.php
@@ -23,7 +23,7 @@
*
* @concrete-extensible
*/
-class PhutilAggregateException extends Exception {
+class PhutilAggregateException extends Exception implements Iterator {
private $exceptions = array();
@@ -33,23 +33,33 @@
$this->exceptions = $other_exceptions;
- $full_message = array();
- $full_message[] = $message;
- foreach ($other_exceptions as $key => $exception) {
- $ex_message =
- (is_string($key) ? $key.': ' : '').
- get_class($exception).': '.
- $exception->getMessage();
- $ex_message = ' - '.str_replace("\n", "\n ", $ex_message);
+ parent::__construct($message);
+ }
+
+
+/* -( Iterator )----------------------------------------------------------- */
+
+ private $pos = 0;
+
+ public function current() {
+ return current($this->exceptions);
+ }
- $full_message[] = $ex_message;
- }
+ public function key() {
+ return key($this->exceptions);
+ }
- parent::__construct(implode("\n", $full_message), count($other_exceptions));
+ public function next() {
+ return next($this->exceptions);
}
- public function getExceptions() {
- return $this->exceptions;
+ public function rewind() {
+ reset($this->exceptions);
}
+ public function valid() {
+ return key($this->exceptions) !== null;
+ }
+
+
}
diff --git a/src/error/PhutilErrorHandler.php b/src/error/PhutilErrorHandler.php
--- a/src/error/PhutilErrorHandler.php
+++ b/src/error/PhutilErrorHandler.php
@@ -244,17 +244,31 @@
* @return void
* @task internal
*/
- public static function handleException(Exception $ex) {
+ public static function handleException(Exception $exception) {
self::dispatchErrorMessage(
self::EXCEPTION,
- $ex,
+ $exception,
array(
- 'file' => $ex->getFile(),
- 'line' => $ex->getLine(),
- 'trace' => self::getRootException($ex)->getTrace(),
+ 'file' => $exception->getFile(),
+ 'line' => $exception->getLine(),
+ 'trace' => self::getRootException($exception)->getTrace(),
'catch_trace' => debug_backtrace(),
));
+ /* if ($exception instanceof PhutilAggregateException) {
+ foreach ($exception->getExceptions() as $ex) {
+ self::dispatchErrorMessage(
+ self::EXCEPTION,
+ $ex,
+ array(
+ 'file' => $ex->getFile(),
+ 'line' => $ex->getLine(),
+ 'trace' => self::getRootException($ex)->getTrace(),
+ 'catch_trace' => debug_backtrace(),
+ ));
+ }
+ }*/
+
// Normally, PHP exits with code 255 after an uncaught exception is thrown.
// However, if we install an exception handler (as we have here), it exits
// with code 0 instead. Script execution terminates after this function
@@ -365,9 +379,19 @@
case self::EXCEPTION:
$messages = array();
$current = $value;
- do {
+
+ if ($current instanceof PhutilAggregateException) {
$messages[] = '('.get_class($current).') '.$current->getMessage();
- } while ($current = self::getPreviousException($current));
+
+ foreach ($current as $ex) {
+ $messages[] = '('.get_class($ex).') '.$ex->getMessage();
+ }
+ } else {
+ do {
+ $messages[] = '('.get_class($current).') '.$current->getMessage();
+ } while ($current = self::getPreviousException($current));
+ }
+
$messages = implode(' {>} ', $messages);
if (strlen($messages) > 4096) {
@@ -384,6 +408,13 @@
$metadata['default_message'] = $default_message;
error_log($default_message);
self::outputStacktrace(self::getRootException($value)->getTrace());
+
+ if ($value instanceof PhutilAggregateException) {
+ foreach ($current as $ex) {
+ self::outputStacktrace($ex->getTrace());
+ }
+ }
+
break;
case self::PHLOG:
$default_message = sprintf(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 3:22 AM (10 h, 30 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6732806
Default Alt Text
D12796.id30910.diff (4 KB)
Attached To
Mode
D12796: Provide stacktraces for aggregate exceptions
Attached
Detach File
Event Timeline
Log In to Comment