Ejemplo n.º 1
0
 /**
  * handle exceptions
  * 
  * @param Zend_Json_Server $server
  * @param Zend_Json_Server_Request_Http $request
  * @param Exception $exception
  * @return Zend_Json_Server_Response
  */
 protected function _handleException($server, $request, $exception)
 {
     $exceptionData = method_exists($exception, 'toArray') ? $exception->toArray() : array();
     $exceptionData['message'] = htmlentities($exception->getMessage(), ENT_COMPAT, 'UTF-8');
     $exceptionData['code'] = $exception->getCode();
     if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
         Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' ' . get_class($exception) . ' -> ' . $exception->getMessage());
     }
     if (Tinebase_Core::getConfig()->suppressExceptionTraces !== TRUE) {
         $exceptionData['trace'] = $this->_getTraceAsArray($exception);
         $this->_logExceptionTrace($exception);
     }
     $server->fault($exceptionData['message'], $exceptionData['code'], $exceptionData);
     $response = $server->getResponse();
     if (null !== ($id = $request->getId())) {
         $response->setId($id);
     }
     if (null !== ($version = $request->getVersion())) {
         $response->setVersion($version);
     }
     return $response;
 }