aboutsummaryrefslogtreecommitdiffstats
path: root/includes/WikiError.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@users.mediawiki.org>2005-03-13 07:22:20 +0000
committerBrion Vibber <brion@users.mediawiki.org>2005-03-13 07:22:20 +0000
commitf3fecc6331ff1e47bf00a3af971abac303159c9f (patch)
tree1d0c716d00ffa846c22d2b5ed9d7b51e7cbdc985 /includes/WikiError.php
parentbae2d2c70cb0d1a8d50c324f8627d0af20edaacc (diff)
downloadmediawikicore-f3fecc6331ff1e47bf00a3af971abac303159c9f.tar.gz
mediawikicore-f3fecc6331ff1e47bf00a3af971abac303159c9f.zip
Fix Special:Import for new schema; make it create page records as needed and hook up the revisions when new.
WikiError class for pseudo-exceptions (must be manually checked, as PHP4 has no exceptions)
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/7665
Diffstat (limited to 'includes/WikiError.php')
-rw-r--r--includes/WikiError.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/includes/WikiError.php b/includes/WikiError.php
new file mode 100644
index 000000000000..65a64556b28a
--- /dev/null
+++ b/includes/WikiError.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * MediaWiki error classes
+ * Copyright (C) 2005 Brion Vibber <brion@pobox.com>
+ * http://www.mediawiki.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @package MediaWiki
+ */
+
+/**
+ * Since PHP4 doesn't have exceptions, here's some error objects
+ * loosely modeled on the standard PEAR_Error model...
+ */
+class WikiError {
+ /**
+ * @param string $message
+ */
+ function WikiError( $message ) {
+ $this->mMessage = $message;
+ }
+
+ /**
+ * @return string Plaintext error message to display
+ */
+ function toString() {
+ return $this->mMessage;
+ }
+
+ /**
+ * Returns true if the given object is a WikiError-descended
+ * error object, false otherwise.
+ *
+ * @param mixed $object
+ * @return bool
+ * @static
+ */
+ function isError( &$object ) {
+ return is_a( $object, 'WikiError' );
+ }
+}
+
+/**
+ * Localized error message object
+ */
+class WikiErrorMsg extends WikiError {
+ /**
+ * @param string $message Wiki message name
+ * @param ... parameters to pass to wfMsg()
+ */
+ function WikiErrorMsg( $message/*, ... */ ) {
+ $args = func_get_args();
+ array_shift( $args );
+ $this->mMessage = wfMsgReal( $message, $args, true );
+ }
+}
+
+/**
+ *
+ */
+class WikiXmlError extends WikiError {
+ /**
+ * @param resource $parser
+ * @param string $message
+ */
+ function WikiXmlError( $parser, $message = '' ) {
+ $this->mXmlError = xml_get_error_code( $parser );
+ $this->mMessage = $message;
+ xml_parser_free( $parser );
+ }
+
+ function toString() {
+ return $this->mMessage . ': ' . xml_error_string( $this->mXmlError );
+ }
+}
+
+?> \ No newline at end of file