Solved

help with zend, handle 503 error

Posted on 2011-03-11
1
449 Views
Last Modified: 2012-05-11
I need to point a 503 error to an error controller that returns a 503 header


Does this look right?

class Errorhandler_Outage extends ZEND_Controller_Action {

      /**
      * errorAction
      */
      public function errorAction(){
                           
            throw new Zend_Controller_Action_Exception(
                  $e->getMessage(), 503);
            }
           
      }
}
0
Comment
Question by:adybee
1 Comment
 
LVL 1

Accepted Solution

by:
DennisBecker earned 500 total points
ID: 35330740
This won't return a header with HTTP status code 503. You should use the default ErrorController where you can set the status code in the response object like the following:
 
<?php

class ErrorController extends Zend_Controller_Action
{

    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');
        
        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
        
                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                
                $this->view->message = 'Page not found';
                
                break;
            default:
                // application error
                $this->getResponse()->setHttpResponseCode(500);
                $this->view->message = 'Application error';
                
                break;
        }
}

Open in new window

Within the switch/case, you can change the default status code 500 to 503 and all should be fine.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now