public function errorAction()
 {
     parent::errorAction();
     $this->view->message = $this->_message;
     $this->view->error = $this->_errorCode;
     if (!empty($this->_validationEntity)) {
         $this->view->entity = $this->_validationEntity;
     }
     if (!empty($this->_validationErrors)) {
         $this->view->validationErrors = $this->_validationErrors;
     }
     if (!empty($this->_errorMessages)) {
         $this->view->errorMessages = $this->_errorMessages;
     }
     if ($this->_exception instanceof Application\Model\Mapper\Exception\EricssonException) {
         $this->view->reason = $this->_exception->getReason();
     }
     //We need a big body to avoid IE bug about error responses inside iFrame
     if ($this->getRequest()->getParam('iframeHack', false)) {
         $hash = md5('I hate IE');
         $this->_helper->output()->setContentType('text/html');
         $this->view->ieHack = str_repeat($hash, 10);
     }
     // TODO Why is sometimes sending response twice??? :S
     Bootstrap::$responseSent = true;
 }
 public function errorAction()
 {
     parent::errorAction();
     $this->_helper->output('proto');
     $this->view->setClass('Application\\Proto\\AsyncNotification\\Service\\Response');
     $this->view->reason = $this->_message;
     /*
            const OK = 0;
            const EXPIRED = 1;
            const UNKNOWN_TOKEN = 2;
            const WRONG_TOKEN = 3;
            const WRONG_PROTO = 4;
            const WRONG_MESSAGE = 5;
            const UNKNOWN = 10;
     */
     // TODO: review exception
     $ex = $this->_exception;
     switch (true) {
         case $ex instanceof Application\Model\Mapper\Exception\MissingCacheException:
             $this->view->code = Application\Proto\AsyncNotification\Service\Response\Code::EXPIRED;
             break;
         case $ex instanceof Application\Model\Mapper\Exception\InvalidArgumentException:
             $this->view->code = Application\Proto\AsyncNotification\Service\Response\Code::WRONG_TOKEN;
             break;
         default:
             $this->view->code = Application\Proto\AsyncNotification\Service\Response\Code::UNKNOWN;
             break;
     }
     // TODO Why is sometimes sending response twice??? :S
     Bootstrap::$responseSent = true;
 }
 public function errorAction()
 {
     parent::errorAction();
     $error = $this->_errSrv->createError($this->_exception);
     if ($error->getHttpCode()) {
         $this->_httpCode = $error->getHttpCode();
         $this->getResponse()->setHttpResponseCode($this->_httpCode);
     }
     if (!empty($this->_errorMessages)) {
         $errMess = array();
         foreach ($this->_errorMessages as $key => $err) {
             if ($err instanceof ModelAbstract) {
                 $err = $err->exportData();
             }
             $errMess[$key] = $err;
         }
         $error->description .= "\n[JSON]\n" . Zend_Json::encode($errMess) . "\n[\\JSON]\n";
     }
     if (!empty($this->_validationErrors)) {
         $errors = array();
         $error->description .= "\n[JSON]\n" . Zend_Json::encode($this->_validationErrors) . "\n[\\JSON]\n";
     }
     $data = $this->_mapError($error);
     if ($error->fault->code === \Externalr12\Model\Error\FaultModel::FAULT_CODE_CLIENT) {
         $this->view->ClientException = $data;
     } else {
         $this->view->ServerException = $data;
     }
 }
 /**
  * Custom exception handler to log the exceptions in the application
  *
  * Exception handlers cannot be chained in PHP so just register this handler
  * in production environments.
  *
  * @param Exception $e the uncatched exception
  */
 public function exceptionHandler($e)
 {
     $log = App::log();
     if (isset($log)) {
         $log->log('<' . get_class($e) . '> ' . $e->getMessage() . ' in ' . $e->getFile() . ' at ' . $e->getLine() . PHP_EOL . $e->getTraceAsString(), Zend_Log::CRIT);
     }
     // Http code
     switch (true) {
         case $e instanceof \Application\Exceptions\InvalidArgumentException:
         case $e instanceof \Application\Exceptions\ValidateException:
             $code = 400;
             break;
         case $e instanceof \Application\Exceptions\UnauthorizedException:
             $code = 401;
             break;
         case $e instanceof \Application\Exceptions\ForbiddenException:
             $code = 403;
             break;
         case $e instanceof \Application\Exceptions\NotFoundException:
             $code = 404;
             break;
         default:
             $code = 500;
     }
     // TODO: What's this suppose to do? Uncatched exceptions should already
     // go thru the error controller.
     $e = App_Controller_Error::fixThirdPartyException($e);
     $this->_sendResponse($code, $e->getCode(), $e->getMessage());
     exit(-1);
 }