예제 #1
0
 /**
  * Throws an previously catched exception while maintaing the propriate stacktrace.
  * 
  * @param	\Exception	$e
  */
 protected function throwException(\Exception $e)
 {
     if ($e instanceof IllegalLinkException) {
         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.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
         } else {
             if ($e instanceof SystemException) {
                 throw new AJAXException($e->getMessage(), AJAXException::INTERNAL_ERROR, $e->__getTraceAsString());
             } else {
                 if ($e instanceof UserInputException) {
                     throw new AJAXException($e->getMessage(), AJAXException::BAD_PARAMETERS);
                 } else {
                     throw new AJAXException($e->getMessage(), AJAXException::INTERNAL_ERROR, $e->getTraceAsString());
                 }
             }
         }
     }
 }
예제 #2
0
	/**
	 * Throws an previously catched exception while maintaing the propriate stacktrace.
	 *
	 * @param	\Exception	$e
	 */
	protected function throwException(\Exception $e) {
		if ($this->inDebugMode) {
			throw $e;
		}
	
		if ($e instanceof IllegalLinkException) {
			throw new AJAXException(WCF::getLanguage()->get('wcf.ajax.error.sessionExpired'), AJAXException::SESSION_EXPIRED, $e->getTraceAsString());
		}
		else if ($e instanceof PermissionDeniedException) {
			throw new AJAXException(WCF::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS, $e->getTraceAsString());
		}
		else if ($e instanceof SystemException) {
			throw new AJAXException($e->getMessage(), AJAXException::INTERNAL_ERROR, $e->__getTraceAsString());
		}
		else if ($e instanceof UserInputException) {
			// repackage as ValidationActionException
			$exception = new ValidateActionException($e->getField(), $e->getType(), $e->getVariables());
			throw new AJAXException($exception->getMessage(), AJAXException::BAD_PARAMETERS, $e->getTraceAsString(), array(
				'errorMessage' => $exception->getMessage(),
				'errorType' => $e->getType(),
				'fieldName' => $exception->getFieldName(),
			));
		}
		else if ($e instanceof ValidateActionException) {
			throw new AJAXException($e->getMessage(), AJAXException::BAD_PARAMETERS, $e->getTraceAsString(), array(
				'errorMessage' => $e->getMessage(),
				'fieldName' => $e->getFieldName()
			));
		}
		else {
			throw new AJAXException($e->getMessage(), AJAXException::INTERNAL_ERROR, $e->getTraceAsString());
		}
	}