jenkins-bot has submitted this change and it was merged.

Change subject: Make error reporting more verbose.
......................................................................


Make error reporting more verbose.

Based on $wgShowExceptionDetails, MWException outputs a stack trace. Our own
implementation omitted this.

It should now still add our own (more user-friendly) error message, but also
call MWException's getHTML, which may output a stack trace too.

Change-Id: Iceb03ea22080903cd4f9897a9bf77428a6100c8e
---
M includes/Exception/ExceptionHandling.php
1 file changed, 41 insertions(+), 2 deletions(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Exception/ExceptionHandling.php 
b/includes/Exception/ExceptionHandling.php
index d20d8c1..84f0864 100644
--- a/includes/Exception/ExceptionHandling.php
+++ b/includes/Exception/ExceptionHandling.php
@@ -61,13 +61,52 @@
        }
 
        /**
+        * Override parent method: we can use wfMessage here
+        *
+        * @return bool
+        */
+       public function useMessageCache() {
+               return true;
+       }
+
+       /**
+        * Overrides MWException getHTML, adding a more human-friendly error 
message
+        *
+        * @return string
+        */
+       public function getHTML() {
+               /*
+                * We'll want both a proper humanized error msg & the 
stacktrace the
+                * parent exception handler generated.
+                * We'll create a stub OutputPage object here, to use its 
showErrorPage
+                * to add our own humanized error message. Then we'll append 
the stack-
+                * trace (parent::getHTML) and then just return the combined 
HTML.
+                */
+               $output = new OutputPage();
+               $output->showErrorPage( 'errorpagetitle', $this->getErrorCode() 
);
+               $output->addHTML( parent::getHTML() );
+               return $output->getHTML();
+       }
+
+       /**
         * Exception from API/commandline will be handled by 
MWException::report(),
         * Overwrite the HTML display only
         */
        public function reportHTML() {
                $this->output->setStatusCode( $this->getStatusCode() );
-               $this->output->showErrorPage( 'errorpagetitle', 
$this->getErrorCode() );
-               $this->output->output();
+
+               /*
+                * Parent exception handler uses global $wgOut
+                * We want to play nice and do inheritance and all, but that 
means we'll
+                * have to cheat here and assign out $this->output to $wgOut in 
order
+                * to have parent::reportHTML use the correct OutputPage object.
+                * After that, restore original $wgOut.
+                */
+               global $wgOut;
+               $wgOutBkp = $wgOut;
+               $wgOut = $this->output;
+               parent::reportHTML(); // this will do ->output() already
+               $wgOut = $wgOutBkp;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/107149
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iceb03ea22080903cd4f9897a9bf77428a6100c8e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: Bsitu <bs...@wikimedia.org>
Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to