SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [ZF]Error handling problems

    I used Zend_Tool for to create the framework project, but as soon i tried to load invalid controllers it didnt give me the exception handling. I tested the plain exception throwing, i get the wanted results, it worked.
    PHP Code:
    <?php
    throw new Exception();
    ech();
    phpinfo();
    ?>
    Here is the ErrorController.php
    PHP Code:
    <?php

    class ErrorController extends Zend_Controller_Action
    {

        public function 
    errorAction()
        {
            echo 
    "CAlled";
            
    $errors $this->_getParam('error_handler');
            
            switch (
    $errors->type) { 
                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;
            }
            
        
    Zend_Debug::dump($erros->exception);
            
    $this->view->exception $errors->exception;
            
    $this->view->request   $errors->request;
        }


    }
    Here is the result of reloading some unknown controller $this->_getParam('error_handler');
    is empty and i dont know why.
    PHP Code:
    An error occurred
    Page not found
    CAlled Notice
    Undefined variableerros in /var/www/php/frame/application/controllers/ErrorController.php on line 26 NoticeTrying to get property of non-object in /var/www/php/frame/application/controllers/ErrorController.php on line 26
    NULL 
    Also i put up the application.ini
    Code:
    [production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    includePaths.library = APPLICATION_PATH "/../library"
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
    bootstrap.class = "Bootstrap"
    resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
    resources.db.adapter = PDO_MYSQL
    resources.db.params.host = localhost
    resources.db.params.username = root
    resources.db.params.password = 123456
    resources.db.params.dbname = andmed
    
    [staging : production]
    
    [testing : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    
    [development : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok the problem itself is easy in .htaccess there is line where the ENV var is setup, but the problem were i haven't allowed to create vars. Delete that line and change the line in file index.php
    PHP Code:
    // Define application environment
    defined('APPLICATION_ENV')
        || 
    define('APPLICATION_ENV''development'); 
    Why the error handling didnt work ? Simple in view there is if statement which cheks the ENV state, so it were default value production which is meant for no errors.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •