Improved exceptions and added language variables
authorAlexander Ebert <ebert@woltlab.com>
Thu, 3 May 2012 13:24:25 +0000 (15:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 3 May 2012 13:24:25 +0000 (15:24 +0200)
wcfsetup/install/files/lib/action/AJAXProxyAction.class.php
wcfsetup/install/files/lib/system/exception/AJAXException.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index e8ba240d337994bf36686645f1b4511dc872ea76..1f6264ef8fca60a01d83800990600bd72efb2095 100644 (file)
@@ -149,10 +149,10 @@ class AJAXProxyAction extends AbstractSecureAction {
         */
        protected function throwException(\Exception $e) {
                if ($e instanceof IllegalLinkException) {
-                       throw new AJAXException(WCF::getLanguage()->get('wcf.global.error.sessionExpired'), AJAXException::SESSION_EXPIRED);
+                       throw new AJAXException(WCF::getLanguage()->get('wcf.global.ajax.error.sessionExpired'), AJAXException::SESSION_EXPIRED);
                }
                else if ($e instanceof PermissionDeniedException) {
-                       throw new AJAXException(WCF::getLanguage()->get('wcf.global.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
+                       throw new AJAXException(WCF::getLanguage()->get('wcf.global.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
                }
                else if ($e instanceof SystemException) {
                        throw new AJAXException($e->getMessage(), AJAXException::INTERNAL_ERROR, $e->__getTraceAsString());
index 6be6ad065b5c432be7be0cb7be055fe1594ee771..eecd80e8921c4bb6163f74a190a00277a5542504 100644 (file)
@@ -71,6 +71,7 @@ class AJAXException extends LoggedException {
                switch ($errorType) {
                        case self::MISSING_PARAMETERS:
                                $statusHeader = 'HTTP/1.0 400 Bad Request';
+                               $responseData['message'] = WCF::getLanguage()->get('wcf.global.ajax.error.badRequest');
                                
                                $this->logError();
                        break;
@@ -93,6 +94,9 @@ class AJAXException extends LoggedException {
                                header('HTTP/1.0 503 Service Unavailable');
                                
                                $responseData['code'] = self::INTERNAL_ERROR;
+                               if (!WCF::debugModeIsEnabled()) {
+                                       $responseData['message'] = WCF::getLanguage()->get('wcf.global.ajax.error.internalError');
+                               }
                                
                                $this->logError();
                        break;
index 3e1f354b15866fabb0df6f9f4562312779fa8b14..d9824a7453fd8420e41e6e26688058d63fb990fe 100644 (file)
        </category>
        
        <category name="wcf.global">
+               <item name="wcf.global.ajax.error.badRequest"><![CDATA[Die Anfrage war unvollständig und konnte nicht verarbeitet werden.]]></item>
+               <item name="wcf.global.ajax.error.internalError"><![CDATA[Es ist ein Fehler bei der Verarbeitung aufgetreten, bitte versuchen Sie es später erneut.]]></item>
+               <item name="wcf.global.ajax.error.permissionDenied"><![CDATA[Sie besitzen leider nicht die notwendigen Zugriffsrechte um diese Aktion auszuführen.]]></item>
+               <item name="wcf.global.ajax.error.sessionExpired"><![CDATA[Ihre Sitzung ist abgelaufen, bitte loggen Sie sich erneut ein.]]></item>
                <item name="wcf.global.button.add"><![CDATA[Hinzufügen]]></item>
                <item name="wcf.global.button.back"><![CDATA[&laquo; Zurück]]></item>
                <item name="wcf.global.button.cancel"><![CDATA[Abbrechen]]></item>
index f4dd29f403b74a1ff66d6869a86d58dc745af123..63fbae4a4ad17109e0784ae550838475d3d1064f 100644 (file)
        </category>
        
        <category name="wcf.global">
+               <item name="wcf.global.ajax.error.badRequest"><![CDATA[The server was unable to proceed your request due to an incomplete request.]]></item>
+               <item name="wcf.global.ajax.error.internalError"><![CDATA[The server encountered an unresolvable problem, please try again later.]]></item>
+               <item name="wcf.global.ajax.error.permissionDenied"><![CDATA[You are not authorized to execute this action.]]></item>
+               <item name="wcf.global.ajax.error.sessionExpired"><![CDATA[Your session expired, please login again.]]></item>
                <item name="wcf.global.button.add"><![CDATA[Add]]></item>
                <item name="wcf.global.button.back"><![CDATA[&laquo; Back]]></item>
                <item name="wcf.global.button.cancel"><![CDATA[Cancel]]></item>