- if ( $wgLogExceptionBacktrace &&
- isset( $context['exception'] ) &&
- $context['exception'] instanceof Exception
- ) {
- $text .= MWExceptionHandler::getRedactedTraceAsString(
- $context['exception']->getTraceAsString()
- ) . "\n";
+ if ( $wgLogExceptionBacktrace && isset( $context['exception'] ) ) {
+ $e = $context['exception'];
+ $backtrace = false;
+
+ if ( $e instanceof Exception ) {
+ $backtrace = MWExceptionHandler::getRedactedTrace( $e );
+
+ } elseif ( is_array( $e ) && isset( $e['trace'] ) ) {
+ // Exception has already been unpacked as structured data
+ $backtrace = $e['trace'];
+ }
+
+ if ( $backtrace ) {
+ $text .= MWExceptionHandler::prettyPrintTrace( $backtrace ) .
+ "\n";
+ }