-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Handling misses catching Exceptions thrown inside controller actions #140
Comments
Unfortunately the Zend Engine does not provide a way to catch PHP exceptions in a C-extension, so currently it isn't possible to catch any kind of exception. We're doing research trying to simulate a try-catch. Most Phalcon's users are using a set_exception_handler to solve this |
Closing this issue since the zend engine cannot produce the result needed. set_exception_handler can be used to catch exceptions with a custom class. |
How about the solution: <?php
use Phalcon\Mvc\Dispatcher as PhalconDispatcher;
use Exception;
class Dispatcher extends PhalconDispatcher {
/**
* Dispatches a handle action taking into account the routing parameters
*
* @return Phalcon\Mvc\Controller
* @throws Exception
*/
public function dispatch() {
try {
return parent::dispatch();
} catch (Exception $exception) {
$result = $this->getEventsManager()->fire('dispatch:beforeException', $this, $exception);
if ($result === false) {
return parent::dispatch();
} else {
throw $exception;
}
}
}
} |
I think I have an idea how to implement this in C, will try to create a PoC code… |
@sjinks this is already implemented in 1.2.1, @mikemirten is posting it as example :) |
I'm just learning a bit more on this feat. So it's intended that, when e.g. creating a Form with an invalid enitity (e.g. One faulty bit, as it does seem to me, is for cases like the above the exception code is 0, which is the same as This is faulty (as it has nothing to do with no DI available)? Related, it also seems to me that the 2nd example of this chapter: http://docs.phalconphp.com/en/latest/reference/dispatching.html#handling-not-found-exceptions is a bit of a (very) bad example.. |
With introducing error handling in the dispatcher here #66
there is still no way to handle errors occuring while processing an action. Lets assume my URI invokes IndexController::indexAction :
Then this exception should be catched in the error handler to be forwarded to the errorAction in ErrorController to render a 500 error page for example. At the moment this is not working :
The text was updated successfully, but these errors were encountered: