Esempio n. 1
0
 /**
  * Send response to the client, render exceptions if they are present.
  */
 public function sendResponse()
 {
     try {
         if ($this->isException()) {
             $this->_renderMessages();
         }
         parent::sendResponse();
     } catch (Exception $e) {
         // If the server does not support all MIME types accepted by the client it SHOULD send 406 (not acceptable).
         $httpCode = $e->getCode() == Mage_Webapi_Exception::HTTP_NOT_ACCEPTABLE ? Mage_Webapi_Exception::HTTP_NOT_ACCEPTABLE : Mage_Webapi_Exception::HTTP_INTERNAL_ERROR;
         /** If error was encountered during "error rendering" process then use error renderer. */
         $this->_errorProcessor->renderException($e, $httpCode);
     }
 }
Esempio n. 2
0
 /**
  * Dispatch request and send response.
  *
  * @return Mage_Webapi_Controller_Front
  */
 public function dispatch()
 {
     try {
         $this->_getDispatcher()->dispatch();
     } catch (Exception $e) {
         $this->_errorProcessor->renderException($e);
     }
     return $this;
 }
Esempio n. 3
0
 /**
  * Test renderException method with turned on Developer mode.
  */
 public function testRenderExecutionInDeveloperMode()
 {
     $this->markTestIncomplete("Think how to replace this test.");
     $_SERVER['HTTP_ACCEPT'] = 'json';
     /** Init base Exception object. */
     $exception = new Exception('Message');
     /** Mock app to return enabled developer mode flag. */
     $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(true));
     /** Assert jsonEncode will be executed once. */
     $this->_helperMock->expects($this->once())->method('jsonEncode');
     $this->_errorProcessor->renderException($exception);
 }