From: Alexander Ebert Date: Mon, 15 Apr 2013 17:47:26 +0000 (+0200) Subject: Fixed exceptions if debug mode is disabled X-Git-Tag: 2.0.0_Beta_1~343^2~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4c4d0cc2a884f0faf717465b2b080ee0504656af;p=GitHub%2FWoltLab%2FWCF.git Fixed exceptions if debug mode is disabled --- diff --git a/wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php b/wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php index 7c7374f100..99e56304e1 100644 --- a/wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php +++ b/wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php @@ -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() : '')); } diff --git a/wcfsetup/install/files/lib/system/exception/AJAXException.class.php b/wcfsetup/install/files/lib/system/exception/AJAXException.class.php index 649a3ca782..c142fc1adc 100644 --- a/wcfsetup/install/files/lib/system/exception/AJAXException.class.php +++ b/wcfsetup/install/files/lib/system/exception/AJAXException.class.php @@ -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: