PHP supports exception chaining. This patch will output the error
message and stack trace not just for the latest exceptions, but for all
exceptions in the chain, using the Exception::getPrevious() method. This
avoids the problem where aftereffects obscure the actual problem, because
only the last exception in the chain was printed.
Change-Id: If577c5c89bb3b3e5766400fff07d8cc0a2d82610
$maintenance->setAgentAndTriggers();
// Do the work
-$success = $maintenance->execute();
+try {
+ $success = $maintenance->execute();
+} catch ( Exception $ex ) {
+ $success = false;
+ while ( $ex ) {
+ $cls = get_class( $ex );
+ print "$cls from line {$ex->getLine()} of {$ex->getFile()}: {$ex->getMessage()}\n";
+ print $ex->getTraceAsString() . "\n";
+ $ex = $ex->getPrevious();
+ }
+}
// Potentially debug globals
$maintenance->globals();