Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8827529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:23:34+00:00 2026-06-14T07:23:34+00:00

Is it possible to have a custom 500 error page for zend framework? I

  • 0

Is it possible to have a custom 500 error page for zend framework? I mean something in the ErrorController…to see a custom view render if you have a 500 Error.

<?php
class ErrorController extends Zend_Controller_Action
{
    private $_notifier;
    private $_error;
    private $_environment;

    public function init()
    {
        parent::init();


        $this->_error = $this->_getParam('error_handler');
   }

    public function errorAction()
    {
        switch ($this->_error->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                $this->getResponse()->setHttpResponseCode(404);
                $this->view->message = 'Page not found';
                break;
            default:
                //Doesn't work
                $this->renderScript('error/500.phtml');
                $this->getResponse()->setHttpResponseCode(500);
            break;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:23:35+00:00Added an answer on June 14, 2026 at 7:23 am

    Yes, it’s completely possible, but it depends on the reason of why you would end up with a status 500 in the first place.

    Anything that results in the Apache webserver emitting this status cannot be intercepted by your ErrorController in an easy way.

    But if you decide a certain action has to be exited with a HTTP response code 500, you are free to do so.

    One important thing is: If you throw an exception that is not catched, the Zend Framework will catch it and redirect to the error controller. This exception object is stored as the property “exception” within the “error_handler” parameter. So in your code you should be able to just ask if you are there because of an uncatched exception:

    if (isset($this->_error->exception) && $this->_error->exception instanceof Exception) {
      // You got an exception
    }
    

    Personally I decided that my controllers are able to throw Controller_Exception which carries the HTTP status code that has to be emitted. Only the controller should decide what happens on the response side if stuff is wrong, if you need the detailed control of response codes.

    About logging: Log errors where they happen. If something makes you throw an exception, the correct location for logging is right before the throw, I’d say. Of course you can always log in the error controller as well, to signal that the error that once might only be at warning level really did not get caught and really is an error, but this might not really tell you where stuff went wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have custom datatype in powershell? I would like to have
Is it possible to have a custom icon displayed for a QAction when it
Is it possible to have scoped macros using custom defined macros through boost wave?
Is it possible to have nested set capabilities in this somewhat custom setup? Consider
Is it possible to log all the transformations in SSIS? I have a custom
Possible Duplicate: mysql custom sort I have an array of IDs: $ids = array(5,
I have noticed that it is possible to define a custom class and then
I have a scenerio where I want to dynamically render a custom form object.
Possible Duplicate: Dismiss keyboard by touching background of UITableView I have a custom UIScrollView
Is it possible to have a custom availability macro like the __OSX_AVAILABLE_STARTING for instance.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.