Improved error handling
authorMarcel Werk <burntime@woltlab.com>
Tue, 2 Jul 2013 19:11:53 +0000 (21:11 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 2 Jul 2013 19:11:53 +0000 (21:11 +0200)
wcfsetup/install/files/acp/templates/dataImport.tpl
wcfsetup/install/files/lib/acp/form/DataImportForm.class.php
wcfsetup/install/files/lib/system/exporter/AbstractExporter.class.php
wcfsetup/install/files/lib/system/exporter/IExporter.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 204ebfa5bd0233f5a6487229f0cf02175009c344..987bfe7eb8847abd0b1c9b901cd9a15d421fb094 100644 (file)
@@ -48,7 +48,7 @@
 </header>
 
 {if $errorField}
-       <p class="error">{lang}wcf.global.form.error{/lang} ({$errorField})</p>
+       <p class="error">{lang}wcf.global.form.error{/lang}</p>
 {/if}
 
 <div class="contentNavigation">
                                
                        </fieldset>*}
                        
-                       <fieldset>
+                       <fieldset{if $errorField == 'database'} class="formError"{/if}>
                                <legend>{lang}wcf.acp.dataImport.configure.database{/lang}</legend>
                                
                                <dl>
                                        <dt><label for="dbPrefix">{lang}wcf.acp.dataImport.configure.database.prefix{/lang}</label></dt>
                                        <dd>
                                                <input type="text" id="dbPrefix" name="dbPrefix" value="{$dbPrefix}" class="short" />
+                                               {if $errorField == 'database'}
+                                                       <small class="innerError">{lang}wcf.acp.dataImport.configure.database.error{/lang}</small>
+                                               {/if}
                                        </dd>
                                </dl>
                        </fieldset>
                        <fieldset>
                                <legend>{lang}wcf.acp.dataImport.configure.fileSystem{/lang}</legend>
                                
-                               <dl>
+                               <dl{if $errorField == 'fileSystemPath'} class="formError"{/if}>
                                        <dt><label for="fileSystemPath">{lang}wcf.acp.dataImport.configure.fileSystem.path{/lang}</label></dt>
                                        <dd>
                                                <input type="text" id="fileSystemPath" name="fileSystemPath" value="{$fileSystemPath}" class="long" />
+                                               {if $errorField == 'fileSystemPath'}
+                                                       <small class="innerError">{lang}wcf.acp.dataImport.configure.fileSystem.path.error{/lang}</small>
+                                               {/if}
                                                <small>{lang}wcf.acp.dataImport.configure.fileSystem.path.description{/lang}</small>
                                        </dd>
                                </dl>
index 55707c6b216cf7ebe76e1ceb7e0737f73d38704c..c65438580f586953b7fced3d24ae885891910a46 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\acp\form;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\form\AbstractForm;
+use wcf\system\database\DatabaseException;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\exception\UserInputException;
 use wcf\system\WCF;
@@ -165,7 +166,11 @@ class DataImportForm extends AbstractForm {
                $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, $this->fileSystemPath);
                
                // validate database Access
-               if (!$this->exporter->validateDatabaseAccess()) {
+               try {
+                       $this->exporter->validateDatabaseAccess();
+               }
+               catch (DatabaseException $e) {
+                       WCF::getTPL()->assign('exception', $e);
                        throw new UserInputException('database');
                }
                
index 5b901c8b304e31bc4606675018d5b830086f25ea..8a9a6d749984a360a87fda514b6f9975ad6c8982 100644 (file)
@@ -99,14 +99,7 @@ abstract class AbstractExporter implements IExporter {
         * @see wcf\system\exporter\IExporter::validateDatabaseAccess()
         */
        public function validateDatabaseAccess() {
-               try {
-                       $this->init();
-               }
-               catch (DatabaseException $e) {
-                       return false;
-               }
-               
-               return true;
+               $this->init();
        }
        
        /**
index fed6217f08a28433158209d743c0031ebfdd5983..4f885294c334267b576b2863d3aaf9e18ac9f10b 100644 (file)
@@ -46,9 +46,9 @@ interface IExporter {
        public function exportData($objectType, $loopCount = 0);
        
        /**
-        * Validates database access. Returns false on failure.
+        * Validates database access.
         *
-        * @return      boolean
+        * @throws      wcf\system\database\DatabaseException
         */
        public function validateDatabaseAccess();
        
index e68708797cee759dad027fd3b69eca1c8b1603a2..657060b9efa5987ebd11809d16cc9076a91f785e 100644 (file)
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.option"><![CDATA[Benutzerprofilfelder]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.follower"><![CDATA[TODO: Wer wem folgt]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.rank"><![CDATA[Benutzeränge]]></item>
+               <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.avatar"><![CDATA[Avatare]]></item>
+               <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.comment"><![CDATA[Pinwand-Kommentare]]></item>
                <item name="wcf.acp.dataImport.configure.database"><![CDATA[Datenbank-Zugang]]></item>
                <item name="wcf.acp.dataImport.configure.database.host"><![CDATA[Hostname]]></item>
                <item name="wcf.acp.dataImport.configure.database.user"><![CDATA[Benutzername]]></item>
                <item name="wcf.acp.dataImport.configure.fileSystem"><![CDATA[Datei-System-Zugang]]></item>
                <item name="wcf.acp.dataImport.configure.fileSystem.path"><![CDATA[Pfad zur Installation]]></item>
                <item name="wcf.acp.dataImport.configure.fileSystem.path.description"><![CDATA[Wird für den Import von Datei-basierten Inhalten (wie z.B. Avatare) benötigt.]]></item>
+               <item name="wcf.acp.dataImport.configure.database.error"><![CDATA[Beim Verbindungsversuch mit der Datenbank ist folgender Fehler aufgetreten:
+               <br /><strong>{$exception->getMessage()}<br />{$exception->getErrorDesc()}</strong>]]></item>
+               <item name="wcf.acp.dataImport.configure.fileSystem.path.error"><![CDATA[Es wurde keine Installation unter dem angegeben Pfad gefunden.]]></item>
        </category>
        
        <category name="wcf.acp.exceptionLog">
index 24fea6185e9fa98599f33eac8068a9df856e519f..880bdcbc0cb31a3ff7079eeb71853c9a9a9c1685 100644 (file)
@@ -172,6 +172,8 @@ Examples for medium ID detection:
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.option"><![CDATA[TODO: Benutzerprofilfelder]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.follower"><![CDATA[TODO: Wer wem folgt]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.rank"><![CDATA[TODO: Benutzeränge]]></item>
+               <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.avatar"><![CDATA[TODO: Avatare]]></item>
+               <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.comment"><![CDATA[TODO: Pinwand-Kommentare]]></item>
                <item name="wcf.acp.dataImport.configure.database"><![CDATA[TODO: Datenbank-Zugang]]></item>
                <item name="wcf.acp.dataImport.configure.database.host"><![CDATA[TODO: Hostname]]></item>
                <item name="wcf.acp.dataImport.configure.database.user"><![CDATA[TODO: Benutzername]]></item>
@@ -181,6 +183,9 @@ Examples for medium ID detection:
                <item name="wcf.acp.dataImport.configure.fileSystem"><![CDATA[TODO: Datei-System-Zugang]]></item>
                <item name="wcf.acp.dataImport.configure.fileSystem.path"><![CDATA[TODO: Pfad zur Installation]]></item>
                <item name="wcf.acp.dataImport.configure.fileSystem.path.description"><![CDATA[TODO: Wird für den Import von Datei-basierten Inhalten (wie z.B. Avatare) benötigt.]]></item>
+               <item name="wcf.acp.dataImport.configure.database.error"><![CDATA[TODO: Beim Verbindungsversuch mit der Datenbank ist folgender Fehler aufgetreten:
+               <br /><strong>{$exception->getMessage()}<br />{$exception->getErrorDesc()}</strong>]]></item>
+               <item name="wcf.acp.dataImport.configure.fileSystem.path.error"><![CDATA[TODO: Es wurde keine Installation unter dem angegeben Pfad gefunden.]]></item>
        </category>
        
        <category name="wcf.acp.exceptionLog">