|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62695 Feature in controller class about exceptions
Submitted: 2012-07-30 14:46 UTC Modified: 2017-10-24 08:00 UTC
From: andreas dot kollaros at gmail dot com Assigned:
Status: Open Package: yaf (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
44 - 23 = ?
Subscribe to this entry?

 [2012-07-30 14:46 UTC] andreas dot kollaros at gmail dot com
I was thinking for a feature in controller class, about exceptions.

Yaf can catch exceptions, by setting catchException to true in application.ini, 
and forwards to the Error controller.

It would be nice to give the developer the chance to rescue this exception 
through a controller method, without turning off the usefull in most cases 
catchException option.

For example, an apllication may not throws only error exceptions. There are 404 
not found exceptions or 401 Unauthorized exceptions or 403 Forbidden exceptions.

A method in controller rescueFromException(Exception $e) would be usefull. 
By default would forward to ErrorController, if catchException is on, but 
developer could overload it and make some checks and forward other controllers, 
according to exceptions.

// This method would be triggered on exceptions
public function rescueFromException(Exception $e)
    if (get_class($e) == 'AccessDenied') {

        $this->forward('index', 'application', 'accessDenied'); 
        // forward to accessDeniedAction and renders a different page than the 
error page.

        header('HTTP/1.0 401 Unauthorized');
        return false;
    } else {
        // forward to ErrorController

fist post here:

Test script:

Expected result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-31 02:51 UTC]
-Assigned To: +Assigned To: laruence
 [2017-10-24 08:00 UTC]
-Status: Assigned +Status: Open -Assigned To: laruence +Assigned To:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Oct 19 22:03:37 2021 UTC