Giter VIP home page Giter VIP logo

Comments (5)

niden avatar niden commented on August 27, 2024

Feedback by Nesbert in the google groups:

+1 for Error handler... in the interim here is an example of how am dealing with issue https://gist.github.com/3701633#L113

from cphalcon.

brandonlamb avatar brandonlamb commented on August 27, 2024

Another +1 for this. With options to configure per module too, set error handler to module, controller, action and pass in exception object or something?

from cphalcon.

johnnyajax avatar johnnyajax commented on August 27, 2024

+1 for error handler.
This is not normal 404 response for production website: http://phalconphp.com/indexxxx
And i can't figure out where and how i can add internal forward like:
$app->dispatcher->forward(array("controller" => "index", "action" => "error404"));

from cphalcon.

niden avatar niden commented on August 27, 2024

Right now the main script of the website as it can be seen in github
encapsulates operations with a try catch.

When an exception happens it only prints out the error message from the
exception.

Working a bit on the try catch code could trap and display things better
until this feature is developed. :)
On Oct 16, 2012 8:07 PM, "JohnnyAjax" [email protected] wrote:

+1 for error handler.
This is not normal 404 response for production website:
http://phalconphp.com/indexxxx

โ€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/66#issuecomment-9511773.

from cphalcon.

 avatar commented on August 27, 2024

0.6.0 now supports an error handler for exceptions produced by the dispatcher

$di->set('dispatcher', function(){

    //Create/Get an EventManager
    $eventsManager = new Phalcon\Events\Manager();

    //Attach a listener
    $eventsManager->attach("dispatch", function($event, $dispatcher, $exception) {

        //The controller exists but the action not
        if ($event->getType() == 'beforeNotFoundAction') {
            $dispatcher->forward(array(
                'controller' => 'index',
                'action' => 'show404'
            ));
            return false;
        }

        //Alternative way, controller or action doesn't exists
        if ($event->getType() == 'beforeException') {
            switch ($exception->getCode()){
                case Phalcon\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                case Phalcon\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                    $dispatcher->forward(array(
                        'controller' => 'index',
                        'action' => 'show404'
                    ));
                    return false;               
            }
        }
    });

    $dispatcher = new Phalcon\Mvc\Dispatcher();

    $dispatcher->setEventsManager($eventsManager);

    return $dispatcher;
});

from cphalcon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.