Ejemplo n.º 1
0
 /**
  * Constructor
  *
  * @param int $httpCode HTTP status code to send to the client
  * @param string|Message $content Content of the message
  * @param string|Message|null $header Content of the header (\<title\> and \<h1\>)
  */
 public function __construct($httpCode, $content, $header = null)
 {
     parent::__construct($content);
     $this->httpCode = (int) $httpCode;
     $this->header = $header;
     $this->content = $content;
 }
 /**
  * @todo Pass around Messages when Status class doesn't suck
  * @param array $msg Message key with parameters
  */
 public function __construct(array $msg)
 {
     $this->msg = $msg;
     // Using ->plain() instead of ->text() due to bug T58226
     $wikitext = call_user_func_array('wfMessage', $msg)->plain();
     parent::__construct($wikitext);
 }
Ejemplo n.º 3
0
 /**
  * Construct a database error
  * @param $db DatabaseBase object which threw the error
  * @param $error String A simple error message to be used for debugging
  */
 function __construct(DatabaseBase &$db, $error)
 {
     global $wgDBcluster;
     $this->db = $db;
     parent::__construct($error);
     $isMaster = !is_null($db->getLBInfo('master'));
     // Wikia change - @author macbre - MAIN-2304
     \Wikia\Logger\WikiaLogger::instance()->error('DBError', ['name' => $db->getDBname(), 'cluster' => $wgDBcluster, 'server' => $db->getServer(), 'server_role' => $isMaster ? 'master' : 'slave', 'errno' => $db->lastErrno(), 'err' => $db->lastError(), 'exception' => $this]);
 }
Ejemplo n.º 4
0
 function getHTML()
 {
     global $wgShowExceptionDetails;
     $class = strtolower(get_class($this->getPrevious()));
     $box_content = wfMessage($class . '-body')->text();
     $box = '<div class="errorbox" style="float: none;">' . $box_content . "</div>";
     if ($wgShowExceptionDetails) {
         $box .= '<b>Status code:</b> ' . $this->previous->getCode() . "<br /><b>Message from authentication server:</b> " . $this->previous->getMessage();
     }
     return $box . parent::getHTML();
 }
Ejemplo n.º 5
0
 function __construct($exceptionID, $engine, $module = null, $line = null, $params = array())
 {
     if ($module) {
         $codelocation = wfMsg('scripting-codelocation', $module, $line);
         $msg = wfMsgExt("scripting-exception-{$engine}-{$exceptionID}", array(), array_merge(array($codelocation), $params));
     } else {
         $msg = wfMsgExt("scripting-exception-{$engine}-{$exceptionID}", array(), $params);
     }
     parent::__construct($msg);
     $this->mExceptionID = $exceptionID;
     $this->mLine = $line;
     $this->mModule = $module;
     $this->mParams = $params;
 }
Ejemplo n.º 6
0
 /**
  * Note: these arguments are keys into wfMessage(), not text!
  *
  * @param string|Message $title Message key (string) for page title, or a Message object
  * @param string|Message $msg Message key (string) for error text, or a Message object
  * @param array $params Array with parameters to wfMessage()
  */
 public function __construct($title, $msg, $params = [])
 {
     $this->title = $title;
     $this->msg = $msg;
     $this->params = $params;
     // Bug 44111: Messages in the log files should be in English and not
     // customized by the local wiki. So get the default English version for
     // passing to the parent constructor. Our overridden report() below
     // makes sure that the page shown to the user is not forced to English.
     if ($msg instanceof Message) {
         $enMsg = clone $msg;
     } else {
         $enMsg = wfMessage($msg, $params);
     }
     $enMsg->inLanguage('en')->useDatabase(false);
     parent::__construct($enMsg->text());
 }
Ejemplo n.º 7
0
 /**
  * Overrides MWException::report to also write exceptions to error_log
  *
  * @see  MWException::report
  */
 function report()
 {
     $file = $this->getFile();
     $line = $this->getLine();
     $message = $this->getMessage();
     $request = RequestContext::getMain()->getRequest();
     $url = '[no URL]';
     if (isset($request)) {
         $url = $request->getFullRequestURL();
     }
     trigger_error("Exception from line {$line} of {$file}: {$message} ({$url})", E_USER_ERROR);
     /*
     bust the headers_sent check in MWException::report()
     Uncomment to override normal MWException headers
     in order to display an error page instead of a 500 error
     WARNING: Varnish doesn't like those
     flush();
     */
     parent::report();
 }
Ejemplo n.º 8
0
 /**
  * Report an exception to the user
  * @param Exception $e
  */
 protected static function report(Exception $e)
 {
     global $wgShowExceptionDetails;
     $cmdLine = MWException::isCommandLine();
     if ($e instanceof MWException) {
         try {
             // Try and show the exception prettily, with the normal skin infrastructure
             $e->report();
         } catch (Exception $e2) {
             // Exception occurred from within exception handler
             // Show a simpler message for the original exception,
             // don't try to invoke report()
             $message = "MediaWiki internal error.\n\n";
             if ($wgShowExceptionDetails) {
                 $message .= 'Original exception: ' . self::getLogMessage($e) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e) . "\n\nException caught inside exception handler: " . self::getLogMessage($e2) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e2);
             } else {
                 $message .= "Exception caught inside exception handler.\n\n" . "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " . "to show detailed debugging information.";
             }
             $message .= "\n";
             if ($cmdLine) {
                 self::printError($message);
             } else {
                 echo nl2br(htmlspecialchars($message)) . "\n";
             }
         }
     } else {
         $message = "Exception encountered, of type \"" . get_class($e) . "\"";
         if ($wgShowExceptionDetails) {
             $message .= "\n" . MWExceptionHandler::getLogMessage($e) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e) . "\n";
         }
         if ($cmdLine) {
             self::printError($message);
         } else {
             echo nl2br(htmlspecialchars($message)) . "\n";
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * @param string $messageName
  * @param array $params
  */
 function __construct($messageName, $params = array())
 {
     if (isset($params['args'])) {
         $this->messageArgs = $params['args'];
     } else {
         $this->messageArgs = array();
     }
     if (isset($params['module']) && isset($params['line'])) {
         $codeLocation = false;
         if (isset($params['title'])) {
             $moduleTitle = Title::newFromText($params['module']);
             if ($moduleTitle && $moduleTitle->equals($params['title'])) {
                 $codeLocation = wfMessage('scribunto-line', $params['line'])->inContentLanguage()->text();
             }
         }
         if ($codeLocation === false) {
             $codeLocation = wfMessage('scribunto-module-line', $params['module'], $params['line'])->inContentLanguage()->text();
         }
     } else {
         $codeLocation = '[UNKNOWN]';
     }
     array_unshift($this->messageArgs, $codeLocation);
     $msg = wfMessage($messageName)->params($this->messageArgs)->inContentLanguage()->text();
     parent::__construct($msg);
     $this->messageName = $messageName;
     $this->params = $params;
 }
Ejemplo n.º 10
0
 /**
  * @dataProvider provideIsCommandLine
  * @covers MWException::isCommandLine
  */
 public function testisCommandLine($expected, $wgCommandLineMode)
 {
     $this->setMwGlobals(array('wgCommandLineMode' => $wgCommandLineMode));
     $e = new MWException();
     $this->assertEquals($expected, $e->isCommandLine());
 }
Ejemplo n.º 11
0
 /**
  * Construct a database error
  * @param Database $db The database object which threw the error
  * @param string $error A simple error message to be used for debugging
  */
 function __construct(Database &$db, $error)
 {
     $this->db =& $db;
     parent::__construct($error);
 }
Ejemplo n.º 12
0
 /**
  * @param string $message
  * @param string $codestr
  * @param int $code
  * @param array|null $extradata
  */
 public function __construct($message, $codestr, $code = 0, $extradata = null)
 {
     parent::__construct($message, $code);
     $this->mCodestr = $codestr;
     $this->mExtraData = $extradata;
 }
Ejemplo n.º 13
0
 /**
  * Construct a database error
  * @param DatabaseBase $db Object which threw the error
  * @param string $error A simple error message to be used for debugging
  */
 function __construct(DatabaseBase $db = null, $error)
 {
     $this->db = $db;
     parent::__construct($error);
 }
 function __construct($message)
 {
     parent::__construct('CLDR plural rule error: ' . $message);
 }
Ejemplo n.º 15
0
	public function __construct( HTMLFormField $field, array $missing ) {
		parent::__construct( sprintf(
			"Form type `%s` expected the following parameters to be set: %s",
			get_class( $field ),
			implode( ', ', $missing )
		) );
	}
Ejemplo n.º 16
0
	/**
	 * @param $msg \string Message key.
	 */
	public function __construct( $msg ) {
		$this->msg = $msg;
		parent::__construct( call_user_func_array( 'wfMsg', $msg ) );
	}
Ejemplo n.º 17
0
 /** @param string $modelId */
 function __construct($modelId)
 {
     parent::__construct("The content model '{$modelId}' is not registered on this wiki.\n" . 'See https://www.mediawiki.org/wiki/Content_handlers to find out which extensions ' . 'handle this content model.');
     $this->modelId = $modelId;
 }
Ejemplo n.º 18
0
 /**
  * Construct a database error
  * @param Database $db The database object which threw the error
  * @param string $error A simple error message to be used for debugging
  */
 function __construct($faultcode, $error = '')
 {
     $this->mFaultCode = $faultcode;
     $this->mFaultText = !empty($error) ? $error : $this->getApiFaultName();
     parent::__construct($this->mFaultText);
 }
Ejemplo n.º 19
0
 /**
  * @param string $message
  * @param string $codestr
  * @param int $code
  * @param array|null $extradata
  */
 public function __construct($message, $codestr, $code = 0, $extradata = null)
 {
     parent::__construct($message, $code);
     $this->mCodestr = $codestr;
     $this->mExtraData = $extradata;
     // This should never happen, so throw an exception about it that will
     // hopefully get logged with a backtrace (T138585)
     if (!is_string($codestr) || $codestr === '') {
         throw new InvalidArgumentException('Invalid $codestr, was ' . ($codestr === '' ? 'empty string' : gettype($codestr)));
     }
 }
Ejemplo n.º 20
0
 /**
  * Override MWException report() and write exceptions to error_log
  *
  * Uncomment the flush() line to override normal MWException headers
  * so we can display an error page instead of a 500 error (varnish doesn't like those)
  *
  * TODO: display a nice walter?
  */
 function report()
 {
     global $wgRequest;
     $file = $this->getFile();
     $line = $this->getLine();
     $message = $this->getMessage();
     $url = '[no URL]';
     if (isset($wgRequest)) {
         $url = $wgRequest->getFullRequestURL();
     }
     trigger_error("Exception from line {$line} of {$file}: {$message} ({$url})", E_USER_ERROR);
     //flush();   // bust the headers_sent check in MWException::report()
     parent::report();
 }
Ejemplo n.º 21
0
 public function __construct()
 {
     parent::__construct("Mediawiki tried to access the database via wfGetDB(). " . "This is not allowed, because database access has been disabled.");
 }
Ejemplo n.º 22
0
 function __construct()
 {
     parent::__construct("Mediawiki tried to access the database via wfGetDB(). " . "This is not allowed.");
 }
Ejemplo n.º 23
0
 /**
  * Note: these arguments are keys into wfMsg(), not text!
  */
 function __construct($title, $msg)
 {
     $this->title = $title;
     $this->msg = $msg;
     parent::__construct(wfMsg($msg));
 }
Ejemplo n.º 24
0
 /**
  * Report an exception to the user
  */
 protected static function report(Exception $e)
 {
     global $wgShowExceptionDetails;
     $cmdLine = MWException::isCommandLine();
     if ($e instanceof MWException) {
         try {
             // Try and show the exception prettily, with the normal skin infrastructure
             $e->report();
         } catch (Exception $e2) {
             // Exception occurred from within exception handler
             // Show a simpler error message for the original exception,
             // don't try to invoke report()
             $message = "MediaWiki internal error.\n\n";
             if ($wgShowExceptionDetails) {
                 $message .= 'Original exception: ' . $e->__toString() . "\n\n" . 'Exception caught inside exception handler: ' . $e2->__toString();
             } else {
                 $message .= "Exception caught inside exception handler.\n\n" . "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " . "to show detailed debugging information.";
             }
             $message .= "\n";
             if ($cmdLine) {
                 self::printError($message);
             } else {
                 self::escapeEchoAndDie($message);
             }
         }
     } else {
         $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class($e) . "\"\n" . $e->__toString() . "\n";
         if ($wgShowExceptionDetails) {
             $message .= "\n" . $e->getTraceAsString() . "\n";
         }
         if ($cmdLine) {
             self::printError($message);
         } else {
             self::escapeEchoAndDie($message);
         }
     }
 }
Ejemplo n.º 25
0
 function __construct($editor, $msg)
 {
     $this->lineNum = $editor->lineNum;
     $this->colNum = $editor->colNum;
     parent::__construct("Parse error on line {$editor->lineNum} " . "col {$editor->colNum}: {$msg}");
 }
 public function __construct($errno, $errstr, $errfile, $errline)
 {
     parent::__construct("Catchable fatal error: {$errstr}", $errno);
     // inherited protected variables from \Exception
     $this->file = $errfile;
     $this->line = $errline;
 }
Ejemplo n.º 27
0
 public function __construct(TException $e)
 {
     $this->innerException = $e;
     parent::__construct('Cassandra error ' . get_class($e) . ': ' . $e->getMessage() . "\n\nStack trace: " . $e->getTraceAsString());
 }