Fixed exceptions if debug mode is disabled
authorAlexander Ebert <ebert@woltlab.com>
Mon, 15 Apr 2013 17:47:26 +0000 (19:47 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 15 Apr 2013 17:47:26 +0000 (19:47 +0200)
wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php
wcfsetup/install/files/lib/system/exception/AJAXException.class.php

index 7c7374f100cafd4e19d46e4b445da6a97bed0a61..99e56304e13160c0208910da83b0e908f6cf6364 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\action;
 use wcf\system\exception\AJAXException;
 use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\NamedUserException;
 use wcf\system\exception\LoggedException;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\SystemException;
@@ -170,6 +171,9 @@ class AJAXInvokeAction extends AbstractSecureAction {
                                'fieldName' => $e->getFieldName()
                        ));
                }
+               else if ($e instanceof NamedUserException) {
+                       throw new AJAXException($e->getMessage(), AJAXException::BAD_PARAMETERS, $e->getTraceAsString());
+               }
                else {
                        throw new AJAXException($e->getMessage(), AJAXException::INTERNAL_ERROR, $e->getTraceAsString(), array(), ($e instanceof LoggedException ? $e->getExceptionID() : ''));
                }
index 649a3ca78261205640802a55e01e9b70f57d9280..c142fc1adc4dcacb3be4574affb9f140ef47a049 100644 (file)
@@ -57,28 +57,23 @@ class AJAXException extends LoggedException {
        public function __construct($message, $errorType = self::INTERNAL_ERROR, $stacktrace = null, $returnValues = array(), $exceptionID = '') {
                if ($stacktrace === null) $stacktrace = $this->getTraceAsString();
                
+               $responseData = array(
+                       'code' => $errorType,
+                       'message' => $message,
+                       'returnValues' => $returnValues
+               );
+               
                if (WCF::debugModeIsEnabled()) {
-                       $responseData = array(
-                               'message' => $message,
-                               'stacktrace' => nl2br($stacktrace)
-                       );
-               }
-               else {
-                       $responseData = array(
-                               'message' => $this->_getMessage()
-                       );
+                       $responseData['stacktrace'] = nl2br($stacktrace);
                }
                
-               $responseData['code'] = $errorType;
-               $responseData['returnValues'] = $returnValues;
-               
                $statusHeader = '';
                switch ($errorType) {
                        case self::MISSING_PARAMETERS:
                                $statusHeader = 'HTTP/1.0 400 Bad Request';
-                               $responseData['message'] = WCF::getLanguage()->get('wcf.ajax.error.badRequest');
                                
-                               $this->logError();
+                               $responseData['exceptionID'] = $exceptionID;
+                               $responseData['message'] = WCF::getLanguage()->get('wcf.ajax.error.badRequest');
                        break;
                        
                        case self::SESSION_EXPIRED:
@@ -91,6 +86,8 @@ class AJAXException extends LoggedException {
                        
                        case self::BAD_PARAMETERS:
                                $statusHeader = 'HTTP/1.0 412 Precondition Failed';
+                               
+                               $responseData['exceptionID'] = $exceptionID;
                        break;
                        
                        default: