Don't mix them in with stdout (which might be redirected,
like dump output, making the errors hard to discover).
Change-Id: Ibed8c0e8dde3e44de60bf32abd3fc5ce5d29e1ba
$success = $maintenance->execute();
} catch ( Exception $ex ) {
$success = false;
+ $exReportMessage = '';
while ( $ex ) {
$cls = get_class( $ex );
- print "$cls from line {$ex->getLine()} of {$ex->getFile()}: {$ex->getMessage()}\n";
- print $ex->getTraceAsString() . "\n";
+ $exReportMessage .= "$cls from line {$ex->getLine()} of {$ex->getFile()}: {$ex->getMessage()}\n";
+ $exReportMessage .= $ex->getTraceAsString() . "\n";
$ex = $ex->getPrevious();
}
+ // Print the exception to stderr if possible, don't mix it in
+ // with stdout output.
+ if ( defined( 'STDERR' ) ) {
+ fwrite( STDERR, $exReportMessage );
+ } else {
+ echo $exReportMessage;
+ }
}
// Potentially debug globals