http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89211
Revision: 89211
Author: freakolowsky
Date: 2011-05-31 08:10:54 +0000 (Tue, 31 May 2011)
Log Message:
-----------
* fixed exception handling in constructor
Modified Paths:
--------------
trunk/extensions/SQL2Wiki/SQL2Wiki.body.php
Modified: trunk/extensions/SQL2Wiki/SQL2Wiki.body.php
===================================================================
--- trunk/extensions/SQL2Wiki/SQL2Wiki.body.php 2011-05-31 07:30:24 UTC (rev
89210)
+++ trunk/extensions/SQL2Wiki/SQL2Wiki.body.php 2011-05-31 08:10:54 UTC (rev
89211)
@@ -77,14 +77,24 @@
if ( !isset( $this->mArgs["database"] ) || !isset(
$wgExSql2WikiDatabases[$this->mArgs["database"]] ) )
throw new Exception( wfMsgForContent(
'sql2wiki-err-invalid_db_id' ) );
+
+ $lastError = null;
+ try {
+ wfSuppressWarnings();
+ $db = $wgExSql2WikiDatabases[$this->mArgs["database"]];
+ $this->mDBType = $db['type'];
+ $this->mDB = Database::newFromType( $this->mDBType, $db
);
+ wfRestoreWarnings();
+ } catch ( Exception $ex) {
+ $lastError = $ex->getMessage();
+ }
- $db = $wgExSql2WikiDatabases[$this->mArgs["database"]];
- $this->mDBType = $db['type'];
- $this->mDB = Database::newFromType( $this->mDBType, $db );
-
- if ( !$this->mDB->isOpen() ) {
- throw new Exception( wfMsgForContent(
'sql2wiki-err-failed_to_connect', $this->mArgs["database"] ) );
+ if ( $lastError == null && !$this->mDB->isOpen() ) {
+ $lastError = $this->mDB->lastError();
+ }
+ if ( $lastError != null ) {
+ throw new Exception( wfMsgForContent(
'sql2wiki-err-failed_to_connect', $this->mArgs["database"] ) . "<br
/>\n$lastError" );
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs